12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
网络知识 时间:2024-11-20 12:07:56
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
对APP数据进行加密的方法有以下几种1.MD5加密使用方法:import hashlibs = '你好,世界!'s = s.encode("utf-8")m = hashlib.md5()m.update(s)psw = m.hexdigest()2.base64加密
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
对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))
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19