Home > other >  Python solution to Caesar's password
Python solution to Caesar's password

Time:10-13

Use simple code to solve

CodePudding user response:

If the plaintext is lowercase letters converted to add capital letters?

CodePudding user response:

 
Def Kaisa_crack (obj) :
Word_list=[' A ', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I' and 'J' and 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
'R' and 'S' and 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
Translation='
N=1
For the word in obj:
If word in word_list:
Word_index=word_list. Index (word) # index values determine the current letter
Word_crack_index=(n + word_index) % 26 # to find out the cracked words alphabet index values
Crack_word=word_list [word_crack_index] # for the cracked letter assignment
Translation +=crack_word # character splicing
Elif word. Upper () in word_list:
Pass # fill in if it is the requirements of the lowercase letter
The else:
Translation +=# other word string the same output
N +=1
Print (translation)

Kaisa_crack (' IWASLEANINGPYTHON)


Output the result is: JYDWQKHVRXRBLHWEE

CodePudding user response:

First put each letter coding based digital number, get the range of 1-26.
Assume the position of the letters in the string as the index, the letter after encoding the Numbers would be: number + index + 1;
Finally get the remainder result_number=(number + index + 1)/26 remainder,
The remainder of the range is 0 to 25, corresponding letters for Z, A, B... Y,
Implementation is easy, I also is new, do not use if the else can the results,
  • Related