Spaces:
Sleeping
Sleeping
Ahmad Hammoudeh
commited on
Commit
·
4cfb9ad
1
Parent(s):
4ac9f49
Update msg_encX.py
Browse files- msg_encX.py +7 -6
msg_encX.py
CHANGED
|
@@ -14,6 +14,7 @@ padding0 = int(os.environ['padding'])
|
|
| 14 |
encryption_difficulty0 = int(os.environ['encryption_difficulty'])
|
| 15 |
N_days0=int(os.environ['N_days'])
|
| 16 |
User_passcode0=int(os.environ['User_passcode'])
|
|
|
|
| 17 |
|
| 18 |
def seedx(path , User_passcode=User_passcode0, N_days=N_days0, encryption_difficulty = encryption_difficulty0):
|
| 19 |
try:
|
|
@@ -26,11 +27,11 @@ def seedx(path , User_passcode=User_passcode0, N_days=N_days0, encryption_diffic
|
|
| 26 |
#total number of days since unix time
|
| 27 |
days_span = timestamp/math.factorial(6)/120 + 0.1#*random.random() #first time calculate the days since unix, thae latter randomize the time zone by up to ~7 hours
|
| 28 |
day_index = math.floor(days_span/N_days)
|
| 29 |
-
seed = int(day_index**
|
| 30 |
if day_index == old_day_index:
|
| 31 |
-
with open('prvt.pem', 'rb') as file:
|
| 32 |
-
key_data = file.read()
|
| 33 |
-
privateKey = rsa.PrivateKey.load_pkcs1(key_data)
|
| 34 |
with open('pblc.pem', 'rb') as file:
|
| 35 |
key_data = file.read()
|
| 36 |
publicKey = rsa.PublicKey.load_pkcs1(key_data)
|
|
@@ -40,8 +41,8 @@ def seedx(path , User_passcode=User_passcode0, N_days=N_days0, encryption_diffic
|
|
| 40 |
#save in a folder
|
| 41 |
with open(path +'indx.txt', 'w') as f:
|
| 42 |
f.write(str(old_day_index))
|
| 43 |
-
with open(path +'prvt.pem', 'w') as f:
|
| 44 |
-
|
| 45 |
with open(path +'pblc.pem', 'w') as f:
|
| 46 |
f.write(publicKey.save_pkcs1().decode('utf-8'))
|
| 47 |
|
|
|
|
| 14 |
encryption_difficulty0 = int(os.environ['encryption_difficulty'])
|
| 15 |
N_days0=int(os.environ['N_days'])
|
| 16 |
User_passcode0=int(os.environ['User_passcode'])
|
| 17 |
+
power0 = int(os.environ['power'])
|
| 18 |
|
| 19 |
def seedx(path , User_passcode=User_passcode0, N_days=N_days0, encryption_difficulty = encryption_difficulty0):
|
| 20 |
try:
|
|
|
|
| 27 |
#total number of days since unix time
|
| 28 |
days_span = timestamp/math.factorial(6)/120 + 0.1#*random.random() #first time calculate the days since unix, thae latter randomize the time zone by up to ~7 hours
|
| 29 |
day_index = math.floor(days_span/N_days)
|
| 30 |
+
seed = int(day_index**power0 + User_passcode)
|
| 31 |
if day_index == old_day_index:
|
| 32 |
+
# with open('prvt.pem', 'rb') as file:
|
| 33 |
+
# key_data = file.read()
|
| 34 |
+
# privateKey = rsa.PrivateKey.load_pkcs1(key_data)
|
| 35 |
with open('pblc.pem', 'rb') as file:
|
| 36 |
key_data = file.read()
|
| 37 |
publicKey = rsa.PublicKey.load_pkcs1(key_data)
|
|
|
|
| 41 |
#save in a folder
|
| 42 |
with open(path +'indx.txt', 'w') as f:
|
| 43 |
f.write(str(old_day_index))
|
| 44 |
+
#with open(path +'prvt.pem', 'w') as f:
|
| 45 |
+
# f.write(privateKey.save_pkcs1().decode('utf-8'))
|
| 46 |
with open(path +'pblc.pem', 'w') as f:
|
| 47 |
f.write(publicKey.save_pkcs1().decode('utf-8'))
|
| 48 |
|