def encrypt_password(p, st, nonce, pk, rsakv):
"""
Encrypting the password using rsa algorithm.
p: password
st: server time
nonce: random value
pk: public key
rsakv: rsa key value
"""
pk = '0x' + pk
pk = int(pk, 16)
msg = str(st) + '\t' + str(nonce) + '\n' + p
key = rsa.PublicKey(pk, 65537)
psw = rsa.encrypt(msg.encode("utf-8"), key)
psw = binascii.b2a_hex(psw)
return decode(psw)
评论列表
文章目录