APP数据如何加密


APP数据如何加密

文章插图

对APP数据进行加密的方法有以下几种1.MD5加密使用方法:import hashlibs = '你好,世界!'s = s.encode("utf-8")m = hashlib.md5()m.update(s)psw = m.hexdigest()2.base64加密使用方法:import base64s = '你好,世界!'s = s.encode("utf-8")s1 = base64.encodestring(s)s2 = base64.decodestring(s1).decode("utf-8")print("原始数据:",s2)print("base64:",s1)3.bcrypt加密使用方法:import bcryptpaswd = "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 AESobj = 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数据如何加密】

    推荐阅读