#coding=utf-8
import string
import base64
encode=""
decode=""
custom = "0ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789+/" #自定义的字符串索引
standard= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" #标准的字符串索引
plainText="GetProcAddr"
if __name__ == "__main__":
#加密
for ch in base64.b64encode(plainText):
if(ch in standard):
encode=encode+custom[string.find(standard,str(ch))]
elif(ch == '='):
encode= encode+'='
print "%s 的非标准base64编码结果为:%s" % (plainText,encode)
print "%s 的标准base64解码结果为:%s" % (encode,base64.b64decode(encode))
#解密
for ch in encode:
if(ch in custom):
decode=decode+standard[string.find(custom,str(ch))]
elif(ch == '='):
decode= decode+'='
decode=base64.b64decode(decode)
print "%s 的非标准base64解码结果为:%s" % (encode,decode)