我是靠谱客的博主 酷酷菠萝,这篇文章主要介绍python3 安装Cryptodome AES,现在分享给大家,希望可以做个参考。

pip install pycryptodome

安装时使用pycryptodome 而不是Cryptodome

from Cryptodome.Cipher import AES

使用:

def add_to_16(text):
if len(text.encode('utf-8'))%16:
add=16 - (len(text.encode('utf-8'))%16)
else:
add=0
text=''.join((text,(''*add)))
return text.encode('utf-8')
#密码加密解密
def passwd_code(logon_key,passwd,type):
mode=AES.MODE_ECB
cryptos_name=AES.new(add_to_16(logon_key),mode)
if type == 'd':
code=a2b_hex(passwd)
pw=cryptos_name.decrypt(code)
try:
pwd_decode=bytes.decode(pw).rstrip('')
except :
print("Error: user or passwd is error:%s / %s" % (logon_key,passwd))
sys.exit(0)
else:
pwd_decode=b2a_hex(cryptos_name.encrypt(add_to_16(passwd)))
return pwd_decode

根据登录用户 对密码进行加密解密

最后

以上就是酷酷菠萝最近收集整理的关于python3 安装Cryptodome AES的全部内容,更多相关python3内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部