Skip to content

Instantly share code, notes, and snippets.

@asimon91
Created November 24, 2015 13:46
Show Gist options
  • Save asimon91/d8847ebbb1aab33cd0d0 to your computer and use it in GitHub Desktop.
Save asimon91/d8847ebbb1aab33cd0d0 to your computer and use it in GitHub Desktop.
#encoding: UTF-8
import os
_CAESAR_ENC = {
'1': '6',
'2': '3',
'3': '4',
'4': '5',
'5': '2',
'6': '7',
'7': '1',
'8': '0',
'9': '8',
'0': '9',
'A': 'W',
'B': 'X',
'C': 'Y',
'Ç': 'Z',
'D': 'Ç',
'E': 'A',
'F': 'B',
'G': 'C',
'H': 'D',
'I': 'E',
'J': 'F',
'K': 'G',
'L': 'H',
'M': 'I',
'N': 'J',
'Ñ': 'K',
'O': 'L',
'P': 'M',
'Q': 'N',
'R': 'Ñ',
'S': 'O',
'T': 'P',
'U': 'Q',
'V': 'R',
'W': 'S',
'X': 'T',
'Y': 'U',
'Z': 'V',
'a': 'u',
'b': 't',
'c': 's',
'ç': 'v',
'd': 'w',
'e': 'o',
'f': 'y',
'g': 'z',
'h': 'ñ',
'i': 'e',
'j': 'c',
'k': 'd',
'l': 'b',
'm': 'f',
'n': 'g',
'ñ': 'h',
'o': 'i',
'p': 'j',
'q': 'k',
'r': 'l',
's': 'm',
't': 'n',
'u': 'a',
'v': 'ç',
'w': 'x',
'x': 'p',
'y': 'q',
'z': 'r',
'.': '!',
',': '.',
'!': '^',
'?': '¡',
' ': '#',
':': '=',
'\n': '_'
}
def main():
with open("/home/deidas/prova.txt", 'r') as f:
linia = f.readline()
text_enc = ''
while linia != '':
for lletra in linia:
if lletra in _CAESAR_ENC.keys():
text_enc += _CAESAR_ENC[lletra]
else:
text_enc += '!'
linia = f.readline()
print "Text encriptat: \n{0}".format(text_enc)
orig = ''
# for lletra in text_enc:
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment