mirror of
https://github.com/autistic-symposium/sec-pentesting-toolkit.git
synced 2025-05-02 14:56:10 -04:00
readms
This commit is contained in:
parent
d8c1966631
commit
800cbd2a97
2 changed files with 59 additions and 2 deletions
27
Cryptography/Rotation-Ciphers/caesarCipher_from_net.py
Normal file
27
Cryptography/Rotation-Ciphers/caesarCipher_from_net.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
def caesar(plaintext,shift):
|
||||
|
||||
alphabet=["a","b","c","d","e","f","g","h","i","j","k","l",
|
||||
"m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
|
||||
|
||||
#Create our substitution dictionary
|
||||
dic={}
|
||||
for i in range(0,len(alphabet)):
|
||||
dic[alphabet[i]]=alphabet[(i+shift)%len(alphabet)]
|
||||
|
||||
#Convert each letter of plaintext to the corrsponding
|
||||
#encrypted letter in our dictionary creating the cryptext
|
||||
ciphertext=""
|
||||
for l in plaintext.lower():
|
||||
if l in dic:
|
||||
l=dic[l]
|
||||
ciphertext+=l
|
||||
|
||||
return ciphertext
|
||||
|
||||
#Example useage
|
||||
plaintext="the cat sat on the mat"
|
||||
print "Plaintext:", plaintext
|
||||
print "Cipertext:",caesar(plaintext,3)
|
||||
#This will result in:
|
||||
#Plaintext: the cat sat on the mat
|
||||
#Cipertext: wkh fdw vdw rq wkh pdw
|
Loading…
Add table
Add a link
Reference in a new issue