
对APP数据进行加密的方法有以下几种
1.MD5加密
使用方法:
import hashlib
s = '你好,世界!'
s = s.encode("utf-8")
m = hashlib.md5()
m.update(s)
psw = m.hexdigest()
2.base64加密
使用方法:
import base64
s = '你好,世界!'
s = s.encode("utf-8")
s1 = base64.encodestring(s)
s2 = base64.decodestring(s1).decode("utf-8")
print("原始数据:",s2)
print("base64:",s1)
3.bcrypt加密
使用方法:
import bcrypt
paswd = "YUjun"
password = paswd.encode("utf-8")
hashed = bcrypt.hashpw(password,bcrypt.gensalt())
print(password)
print(hashed)
if bcrypt.hashpw(password,hashed) == hashed:
print("It maches!")
else:
print("It does not match:(")
4.AES加密
使用方法:
from Crypto.Cipher import AES
obj = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456')
message = "The answer is no"
ciphertext = obj.encrypt(message)
print(ciphertext)
obj2 = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456')
print(obj2.decrypt(ciphertext))
以上就是关于“APP数据如何加密”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm