Thursday, April 25, 2019

Find plain text messages and key information corresponds to following cipher text messages using Brute-Force technique on Caesar cipher - System Security | Python3

a=input("Enter the msg: ")
pt=[]

print ("Decrypted Data")
for key in range(1,27):
    for i in a:
        if ord(i)>=97 and ord(i)<=122:  
            d=(((ord(i)-key)-97)%26)+97
            pt.append(chr(d))
        elif ord(i)>=62 and ord(i)<=90:
            d=(((ord(i)-key)-65)%26)+65
            pt.append(chr(d))    
    str2 = ''.join(pt)
    print ("Key %d = %s" % (key,str2))
    pt=[]

Screenshot:


No comments:

Post a Comment