非标准base64编码

#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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值