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
51
Cryptography/Rotation-Ciphers/cesarCipher_simple_2.py
Normal file
51
Cryptography/Rotation-Ciphers/cesarCipher_simple_2.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
|
||||
__author__ = "Mari Wahl"
|
||||
__email__ = "marina.w4hl@gmail.com"
|
||||
|
||||
'''
|
||||
Cesar encrypt - better
|
||||
'''
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def encrypt(message, k):
|
||||
cipher = ''
|
||||
for c in message:
|
||||
c = (ord(c) + k) % 26
|
||||
if c < 32:
|
||||
c += 32
|
||||
cipher += chr(c)
|
||||
return cipher
|
||||
|
||||
|
||||
|
||||
def decrypt(message, k):
|
||||
cipher = ''
|
||||
for c in message:
|
||||
c = (ord(c) - k) % 26
|
||||
if c < 32:
|
||||
c += 126-32
|
||||
cipher += chr(c)
|
||||
return cipher
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
#MESSAGE = list(raw_input('Enter the message to be encrypted: ')) or "all your basis belong to us"
|
||||
MESSAGE = 'jxu qdimuh je jxyi ijqwu yi qdimuhxuhu'
|
||||
for k in range (13, 14):
|
||||
|
||||
#encrypted_msg = encrypt(MESSAGE, k)
|
||||
#print("Encrypted message: " + encrypted_msg)
|
||||
|
||||
|
||||
decrypted_msg = decrypt(MESSAGE, k)
|
||||
print("Decrypted message: " + decrypted_msg)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue