云服务器网:购买云服务器和VPS必上的网站!

数据:APP数据怎么加密

APP数据怎样加密对APP数据进行加密的方法有以下几种1.MD5加密使用方法:import hashlibs = \’你好,世界!\’s = s.encode(\”utf⑻\”)m = hashlib.md5()m.update(s)psw = m.hexdigest

APP数据怎样加密

对APP数据进行加密的方法有以下几种

1.MD5加密

使用方法:

import hashlib

s = '你好,世界!'

s = s.encode("utf⑻")

m = hashlib.md5()

m.update(s)

psw = m.hexdigest()

2.base64加密

使用方法:

import base64

s = '你好,世界!'

s = s.encode("utf⑻")

s1 = base64.encodestring(s)

s2 = base64.decodestring(s1).decode("utf⑻")

print("原始数据:",s2)

print("base64:",s1)

3.bcrypt加密

使用方法:

import bcrypt

paswd = "YUjun"

password = paswd.encode("utf⑻")

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

本文来源:https://www.yuntue.com/post/60142.html | 云服务器网,转载请注明出处!

关于作者: yuntue

云服务器(www.yuntue.com)是一家专门做阿里云服务器代金券、腾讯云服务器优惠券的网站,这里你可以找到阿里云服务器腾讯云服务器等国内主流云服务器优惠价格,以及海外云服务器、vps主机等优惠信息,我们会为你提供性价比最高的云服务器和域名、数据库、CDN、免费邮箱等企业常用互联网资源。

为您推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注