dynamic create crypto_key when django running

This commit is contained in:
向乐🌌
2021-05-20 13:11:55 +08:00
parent ca84457c1f
commit 28661b0d9c
4 changed files with 42 additions and 47 deletions

View File

@@ -1,11 +1,4 @@
import os
import random
try:
from cryptography.fernet import Fernet
except ImportError:
os.system('pip3 install cryptography')
from cryptography.fernet import Fernet
from cryptography.fernet import Fernet
class Crypto(object):
@@ -22,8 +15,3 @@ class Crypto(object):
def decrypt(self, token):
string = self.factory.decrypt(bytes(token.encode('utf-8'))).decode('utf-8')
return string
if __name__ == '__main__':
key = Fernet.generate_key()
print(key)