H4CK3R-5M4CK3R commited on
Commit
3ba8256
·
1 Parent(s): 35d3eb1

updated crypto

Browse files
Files changed (2) hide show
  1. app.py +2 -3
  2. crypto.py +30 -0
app.py CHANGED
@@ -13,6 +13,7 @@ import random
13
  import string
14
  import json
15
  import base64
 
16
 
17
  auth = [
18
  (os.getenv("USERNAME1"), os.getenv("PASSWORD1")),
@@ -346,9 +347,7 @@ def handle_url(url, From_volume: int, To_Volume: int, Gmail: str, FolderId: str,
346
  details = []
347
  final_output = None
348
  link = None
349
- credit = os.getenv("GOOGLE_AUTH_CREDENTIALS") # Get the google auth from the env
350
- credit = base64.b64decode(credit).decode()
351
- print(credit)
352
  credit = json.loads(credit)
353
 
354
  for key, result in enumerate(filterUrlandRun(url, From_volume, To_Volume, Reverse, Output, MakeOwner, Gmail, FolderId, credit=credit, usegooglesheet=UseGoogleSheet)):
 
13
  import string
14
  import json
15
  import base64
16
+ import crypto
17
 
18
  auth = [
19
  (os.getenv("USERNAME1"), os.getenv("PASSWORD1")),
 
347
  details = []
348
  final_output = None
349
  link = None
350
+ credit = crypto.decrypt(os.getenv("KEY"), os.getenv("GOOGLE_AUTH_CREDENTIALS"))
 
 
351
  credit = json.loads(credit)
352
 
353
  for key, result in enumerate(filterUrlandRun(url, From_volume, To_Volume, Reverse, Output, MakeOwner, Gmail, FolderId, credit=credit, usegooglesheet=UseGoogleSheet)):
crypto.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from cryptography.fernet import Fernet
2
+
3
+ def decrypt(key: str, data_to_decrypt: str) -> str:
4
+ '''
5
+ here key is the decryption key and data will be encrypted data
6
+ '''
7
+ try:
8
+ key = Fernet(key)
9
+ decrypted_datas = key.decrypt(data_to_decrypt.encode())
10
+ return decrypted_datas.decode()
11
+ except:
12
+ return None
13
+
14
+ def encrypt(key: str, data_to_encrypt: str) -> str:
15
+ '''
16
+ here key is the decryption key and data will be text which needs to be decrypted
17
+ '''
18
+ try:
19
+ key = Fernet(key)
20
+ encrypted_data = key.encrypt(data_to_encrypt.encode())
21
+ return encrypted_data.decode()
22
+ except:
23
+ return None
24
+
25
+ def create_new_key() -> str:
26
+ '''
27
+ this section is use to create a new key
28
+ '''
29
+ key = Fernet.generate_key()
30
+ return key.decode()