Notepad v16

I decided to add some more to my notepad application,  rather than trying to use gpg encryption I am going for the simple ROT13 encoding.   I found and slightly modified the solution from here so all credit to that website.

and back

The String THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG contains all letters of the alphabet,  encoded it reads GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT

It is not encryption but if a users sees the latter in normal text file then it may not look like anything interesting.

My code is simply modified from the website and integrated in to my application.

def rot13_encode():
	#print ("rot 13 encoding")
	sourceString = txt.get('1.0', END+'-1c')
	print sourceString
	resultString = "";
	for char in sourceString:
		if char.isupper():
			resultString += encrypt(char, UPPER_LETTERS);
		elif char.islower():
			resultString += encrypt(char, LOWER_LETTERS);
		else:
			resultString += char;
	#print("The rot13 string is:%s" % (resultString));	
	txt.delete(1.0, END)
	txt.insert(END, resultString)
 
def encrypt(char, letterList):
    resultchar = '';
    originalIndex = letterList.index(char)
    newIndex = originalIndex + 13
    resultchar += letterList[newIndex % len(letterList)]
    return resultchar

I also made it so that it would delete the original text string before inserting the new encoded text string.