Tianyi (Alex) Qiu commited on
Commit
c106903
·
1 Parent(s): 89ebaab

add decrypt

Browse files
Files changed (1) hide show
  1. src/envs.py +7 -1
src/envs.py CHANGED
@@ -29,4 +29,10 @@ API = HfApi(token=TOKEN)
29
 
30
  with open('pubkey.pem', 'rb') as f:
31
  pub = f.read()
32
- RSA_PUBKEY = rsa.PublicKey.load_pkcs1(pub)
 
 
 
 
 
 
 
29
 
30
  with open('pubkey.pem', 'rb') as f:
31
  pub = f.read()
32
+ RSA_PUBKEY = rsa.PublicKey.load_pkcs1(pub)
33
+
34
+ def decrypt_email(email_encrypted: str) -> str:
35
+ with open('privkey.pem', mode='rb') as f:
36
+ prikey = rsa.PrivateKey.load_pkcs1(f.read())
37
+
38
+ return rsa.decrypt(bytes.fromhex(email_encrypted), prikey).decode()