Tianyi (Alex) Qiu
add decrypt
c106903
import os
from huggingface_hub import HfApi
import rsa
# Info to change for your repository
# ----------------------------------
TOKEN = os.environ.get("TOKEN") # A read/write token for your org
OWNER = "PKU-Alignment" # Change to your org - don't forget to create a results and request dataset, with the correct format!
# ----------------------------------
REPO_ID = f"{OWNER}/ProgressGym-LeaderBoard"
DATA_REPO = f"{OWNER}/ProgressGym-LeaderBoardData"
RESULTS_REPO_PATH = 'eval-results/'
REQUESTS_REPO_PATH = 'eval-queue/'
# If you setup a cache later, just change HF_HOME
CACHE_PATH=os.getenv("HF_HOME", ".")
# Local caches
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue")
EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results")
EVAL_REQUESTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-queue-bk")
EVAL_RESULTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-results-bk")
API = HfApi(token=TOKEN)
with open('pubkey.pem', 'rb') as f:
pub = f.read()
RSA_PUBKEY = rsa.PublicKey.load_pkcs1(pub)
def decrypt_email(email_encrypted: str) -> str:
with open('privkey.pem', mode='rb') as f:
prikey = rsa.PrivateKey.load_pkcs1(f.read())
return rsa.decrypt(bytes.fromhex(email_encrypted), prikey).decode()