python - base64-- simple encryption and decryption

Import Base64 

A = " Liming I am Chinese " 
bytesString = a.encode (encoding = " UTF-8 " )   # transcoding - turn into a string of bytes in the form of a string 
# b'liming \ XE6 \ X88 \ x91 \ XE6 \ X98 \ XAF \ XE4 \ XB8 \ XAD \ xe5 \ X9b \ XBD \ XE4 \ Xba \ Xba ' 

encodestr = base64.b64encode (bytesString)   # encryption 
# parameters: byte string of the form 
# b'bGltaW5n5oiR5piv5Lit5Zu95Lq6' 
X encodestr.decode = ()   # decoding - a string of bytes translated into strings 
# bGltaW5n5oiR5piv5Lit5Zu95Lq6 

decodestr = base64.b64decode (encodestr)   # decryption 
#b'liming\xe6\x88\x91\xe6\x98\xaf\xe4\xb8\xad\xe5\x9b\xbd\xe4\xba\xba'

x=decodestr.decode()

print(encodestr,decodestr,x)

 

 

 

Guess you like

Origin www.cnblogs.com/liming19680104/p/12151879.html