Python简单字符串加密

加密



import base64

def encode(str):
	data = base64.b64encode(str)
	encode = []
	for i in range(len(data)):
		encode.append( '%d' % data[i] )
	encode = '-'.join(encode)
	return encode

def decode(str):
	encode = str.split('-')
	decode = []
	for i in encode:
		decode.append( chr( int(i) ) )
	decode = ''.join(decode)
	return base64.b64decode(decode.encode())