Topic:
Problem Solving Ideas:
According to the k→m,o→q,e→g in the figure, we can find that the K,o,e three letters are moved backwards by 2 bits. Caesar is said to be the first to use this encryption method, so it is named Caesar password. The basic idea is to encrypt and decrypt letters by moving a certain number of digits.
Implementation method:
Import STRINGOLD_CHR = "G FMNC wms Bgblr RPYLQJYRC gr ZW fylb. RFYRQ Ufyr AMKNSRCPQ ypc DMP. Bmgle GR GL ZW fylb GQ glcddgagclr ylb rfyr ' q UFW rfgq rcvr GQ QM Jmle. Sqgle QRPGLE.KYICRPYLQ () GQ PCAMKKCLBCB. LMU ynnjw ml RFC spj. " A = String.lowercaseb = a[2:] + A[:2]a_to_b = String.maketrans (A, b) new_chr = String.translate (old_chr,a_to_b) Print New_ch R
Method Explanation:
- The String.lowercase method will output a A-Z of these 26 letters, and if you want to output other contiguous letters, you can fragment them, such as string.lowercase[:7] will output ' ABCDEFG '.
- With shard processing, the first two of the 26 letters are moved to the end, forming a new sequence of all the letters moving backwards two bits.
- The String.maketrans method takes two parameters (From,to) to form a conversion table from the from to to, which is passed into the translate method as a parameter.
- The String.translate method accepts three parameters (String,table,deletechars). Where Deletechars is an optional parameter that is used to delete characters from the original string. The Translate method converts a string based on the conversion table.
Output:
I hope you didnt translate it by hand. Thats what computers is for. Doing it in by hand are inefficient and that's why the this text was so long. Using String.maketrans () is recommended. Now apply to the URL.
Finally, apply this method to the map in the URL and change the map to OCR to go to the next pass.
Pythonchallenge 1: The decoding of Caesar's code