[英]How to encrypt data with RSA private key (not normal signing) in Python?
[英]Python RSA Private Key signing error
我想使用rsa私鑰簽名並使用sha-256對其進行編碼,但是我始終遇到此錯誤
TypeError: Unicode-objects must be encoded before hashing
這是代碼片段:
private_key = rsa.PrivateKey.load_pkcs1(open('private.pem', 'rb').read())
signature = rsa.sign(sign, private_key, 'SHA-256')
你能幫我嗎?
編碼為“ utf-8”應該適合您。
private_key = rsa.PrivateKey.load_pkcs1(open('private_key.pem', 'rb').read())
signature = rsa.sign(sign.encode("utf-8"), private_key, 'SHA-256')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.