注:本人使用的是python2.7
直接上代码:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import base64
str = 'DAWWN IS A NICE MAN'
#加密
encodestr = base64.b64encode(str)
print '===='
print encodestr
#解密
decodestr = base64.b64decode(encodestr)
print decodestr
print '---------------'
#base32
bs32=base64.b32encode(str)
print bs32
db32 = base64.b32decode(bs32)
print db32
print '....................'
bs16 = base64.b16encode(str)
print bs16
db16 =base64.b16decode(bs16)
print db16