Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def encrypter(intext, shift, modder):
- plain = list(intext)
- out = ''
- j = 0
- key = list(shift)
- for i in plain:
- if mod > 0:
- x = chr((ord(i) + ord(key[(j % (len(plain) - 1)) % len(key)]) - 48) % 58 + 48)
- if mod < 0:
- x = chr(((ord(i) - ord(key[(j % (len(plain) - 1)) % len(key)]) - 48) % 58 + 48))
- out += x
- j += 1
- return out
- sel = raw_input("Encrypt (e)/ Decrypt (d)")
- if sel == 'e':
- mod = 1
- elif sel == 'd':
- mod = -1
- else:
- mod = 0
- print('Enter a proper value!')
- if mod != 0:
- print(encrypter(raw_input('Enter the text:'), raw_input('Enter the key-phrase:'), mod)
- C:Usersaesha_000pyScriptspython.exe "D:/Programming/Computing GCSE/Resources/functiontest3.py"
- Encrypt (e)/ Decrypt (d)e
- Enter the text:alex
- Enter the key-phrase:pass
- ]Yd:
- Process finished with exit code 0
- C:Usersaesha_000pyScriptspython.exe "D:/Programming/Computing GCSE/Resources/functiontest3.py"
- Encrypt (e)/ Decrypt (d)d
- Enter the text:]Yd:
- Enter the key-phrase:pass
- a2e>
- Process finished with exit code 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement