simonn8 commited on
Commit
11ee225
1 Parent(s): 032acdc

encrypt user

Browse files
Files changed (3) hide show
  1. app.py +6 -1
  2. generate_key.py +7 -0
  3. requirements.txt +2 -1
app.py CHANGED
@@ -6,9 +6,12 @@ import json
6
  import os
7
  from huggingface_hub import upload_file
8
  from datetime import datetime
 
9
 
10
  HF_TOKEN = os.environ.get("HF_TOKEN")
11
  print("is none?", HF_TOKEN is None)
 
 
12
 
13
  user = st.sidebar.text_input("User", "your.email@provider.com")
14
 
@@ -79,8 +82,10 @@ else:
79
  if user == "your.email@provider.com":
80
  st.sidebar.error(f"Please provide your email adress")
81
  else:
 
 
82
  with open("rate_results.jsonl", "a", encoding="utf-8") as jsonl:
83
- rating_data = {"user": user, "ratings": st.session_state.html_ratings, "timestamp": datetime.now().isoformat()}
84
  jsonl.write(json.dumps(rating_data, ensure_ascii=False))
85
  jsonl.write("\n")
86
  upload_file(
 
6
  import os
7
  from huggingface_hub import upload_file
8
  from datetime import datetime
9
+ from cryptography.fernet import Fernet
10
 
11
  HF_TOKEN = os.environ.get("HF_TOKEN")
12
  print("is none?", HF_TOKEN is None)
13
+ FERNET_KEY = os.environ.get("FERNET_KEY")
14
+ print("FERNET_KEY is none?", FERNET_KEY is None)
15
 
16
  user = st.sidebar.text_input("User", "your.email@provider.com")
17
 
 
82
  if user == "your.email@provider.com":
83
  st.sidebar.error(f"Please provide your email adress")
84
  else:
85
+ fernet = Fernet(FERNET_KEY)
86
+ encrypted_user = fernet.encrypt(user.encode())
87
  with open("rate_results.jsonl", "a", encoding="utf-8") as jsonl:
88
+ rating_data = {"user": encrypted_user, "ratings": st.session_state.html_ratings, "timestamp": datetime.now().isoformat()}
89
  jsonl.write(json.dumps(rating_data, ensure_ascii=False))
90
  jsonl.write("\n")
91
  upload_file(
generate_key.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from cryptography.fernet import Fernet
2
+ import os
3
+
4
+ # key = Fernet.generate_key()
5
+
6
+ print(key)
7
+
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- huggingface_hub
 
 
1
+ huggingface_hub
2
+ cryptography