mirror of
https://github.com/autistic-symposium/sec-pentesting-toolkit.git
synced 2025-05-03 15:24:59 -04:00
Reorganized
This commit is contained in:
parent
ab54dc8e70
commit
2afd831662
281 changed files with 253 additions and 33 deletions
44
Cryptography/Rotation-Ciphers/cesarCipher_simple.py
Normal file
44
Cryptography/Rotation-Ciphers/cesarCipher_simple.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
|
||||
__author__ = "Mari Wahl"
|
||||
__email__ = "marina.w4hl@gmail.com"
|
||||
|
||||
'''
|
||||
Cesar Ecrypt
|
||||
'''
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def encrypt(message, k):
|
||||
alphabet = list('abcdefghijklmnopqrstuvwxyz ')
|
||||
cipher = ''
|
||||
for c in message:
|
||||
cipher += alphabet[(alphabet.index(c) + k)%(len(alphabet))]
|
||||
return cipher
|
||||
|
||||
|
||||
def decrypt(message, k):
|
||||
alphabet = list('abcdefghijklmnopqrstuvwxyz ')
|
||||
decipher = ''
|
||||
for c in message:
|
||||
decipher += alphabet[(alphabet.index(c) - k)%(len(alphabet))]
|
||||
return decipher
|
||||
|
||||
|
||||
def main():
|
||||
MESSAGE = list(raw_input('Enter the message to be encrypted: ')) or "all your basis belong to us"
|
||||
k = 13
|
||||
|
||||
encrypted_msg = encrypt(MESSAGE, k)
|
||||
print("Encrypted message: " + encrypted_msg)
|
||||
|
||||
|
||||
decrypted_msg = decrypt(encrypted_msg, k)
|
||||
assert(decrypted_msg == MESSAGE)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue