Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 2d9ca8b

Browse files
authored
Update sign_cryptography.py
fix python3 read() return is utf-8 to ascii
1 parent 0e50795 commit 2d9ca8b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

adb/sign_cryptography.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,20 @@ class CryptographySigner(adb_protocol.AuthSigner):
2626

2727
def __init__(self, rsa_key_path):
2828
with open(rsa_key_path + '.pub') as rsa_pub_file:
29-
self.public_key = rsa_pub_file.read()
29+
rsa_data = rsa_pub_file.read()
30+
if isinstance (rsa_data,str):
31+
self.public_key = rsa_data
32+
else:
33+
self.public_key = rsa_data.encode('ascii')
3034

3135
with open(rsa_key_path) as rsa_prv_file:
32-
self.rsa_key = serialization.load_pem_private_key(
33-
rsa_prv_file.read(), None, default_backend())
36+
rsa_data = rsa_prv_file.read()
37+
if isinstance (rsa_data,str):
38+
self.rsa_key = serialization.load_pem_private_key(
39+
rsa_data, None, default_backend())
40+
else:
41+
self.rsa_key = serialization.load_pem_private_key(
42+
rsa_data.encode('ascii'), None, default_backend())
3443

3544
def Sign(self, data):
3645
return self.rsa_key.sign(

0 commit comments

Comments
 (0)