File tree Expand file tree Collapse file tree 5 files changed +75
-0
lines changed Expand file tree Collapse file tree 5 files changed +75
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change
1
+ {
2
+ "ADMIN_KEY" : " exampleadmin123" ,
3
+ "ADMIN_PASSWORD" : " Darwin@Example2506" ,
4
+ "ADMIN_USERNAME" : " example@admin" ,
5
+ "FACEBOOK_API_KEY_SECRET" : " 7jewkdjwenbnsH" ,
6
+ "INSTA_API_KEY" : " Qhsh6yihijy3e8" ,
7
+ "TWITTER_ACCESS_TOKEN" : " 1234614-4Du6ZlFtVOpNMgtwIKjRe4wzwxHejcDRaxjNmAU" ,
8
+ "YOUTUBE_API_KEY" : " 83nicciwdcIIUNij"
9
+ }
Original file line number Diff line number Diff line change
1
+ from cryptography .fernet import Fernet
2
+ import os
3
+
4
+ def keygen ():
5
+ try :
6
+
7
+
8
+ from cryptography .fernet import Fernet
9
+ #generating the key and storing them in a file
10
+ key = Fernet .generate_key ()
11
+ #creating the key file in which the key'll be stored
12
+ file = open ('key.key' ,'wb' )
13
+ file .write (key )
14
+ file .close ()
15
+ print ("The key is succesfully generated." )
16
+ except :
17
+ print ("The Key could not be generated!" )
18
+
19
+ def encyption (key1 ):
20
+
21
+
22
+ try :
23
+ with open ('test_data/apikeys.json' ,'rb' ) as f :
24
+ data = f .read ()
25
+
26
+ #encrypting the data from the given file name
27
+
28
+ fernet = Fernet (key1 )
29
+ encrypted = fernet .encrypt (data )
30
+ os .remove ('test_data/apikeys.json' ) #deleting the file with the original api key
31
+
32
+ with open ('new.json' ,'wb' ) as f :
33
+ f .write (encrypted )
34
+ except :
35
+
36
+ print ("The File could not be encrypted" )
37
+
38
+ def decrypt (key1 ):
39
+ try :
40
+
41
+
42
+
43
+ with open ('new.json' ,'rb' ) as f :
44
+ data = f .read ()
45
+ q = Fernet (key1 )
46
+ decrypted_message = q .decrypt (data )
47
+
48
+ with open ('decrypted.json' ,'wb' ) as f :
49
+ f .write (decrypted_message )
50
+ except :
51
+ ("This file could not be Decypted" )
52
+
53
+
54
+
55
+
56
+
57
+ #keygen()
58
+ #taking key as user input
59
+ key1 = input ("enter the encyption key" )
60
+ #encyption(key1)
61
+ decrypt (key1 )
62
+
63
+
64
+
65
+
Original file line number Diff line number Diff line change
1
+ djLVPXylPE5THh-BD7wHUiUP_Vt3z3gnjqHx2FmkoiQ=
You can’t perform that action at this time.
0 commit comments