String [special metamorphosis] method

"a".x.join()---Convert the list into a string [a means that the link value can be a space character]

x.maketrans()----generate codebook

x.translate()------encryption

Give a chestnut to demonstrate the encryption process

1. Use all characters of the string as the encrypted data source [string.tab] string.printable is the method of all characters in python

2. After defining variables, use str.maketrans(source, output) to generate codebook

Then use msg.translate(pwd) to encrypt, the execution result is as follows

Decryption: It is to generate a codebook. Since the order of characters is reversed when generating a password, decryption is to reverse the characters. str.maketrans(output,source)

Guess you like

Origin blog.csdn.net/qq_42954795/article/details/127489193