2021-10-19 16:14:33 +11:00
|
|
|
import uuid
|
|
|
|
import base64
|
|
|
|
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
|
|
|
from cryptography.hazmat.primitives.padding import PKCS7
|
|
|
|
from cryptography.hazmat.backends import default_backend
|
|
|
|
backend=default_backend()
|
|
|
|
|
2022-10-18 07:54:13 +11:00
|
|
|
p=''
|
|
|
|
|
2021-10-19 16:14:33 +11:00
|
|
|
import json
|
|
|
|
with open('conf.json') as b:
|
|
|
|
conf=json.load(b)
|
|
|
|
uid=conf['uid']['prepared']
|
|
|
|
|
|
|
|
def generateuuid():
|
|
|
|
uid=uuid.uuid4()
|
|
|
|
return base64.b64encode(cipher_encode(str(uid))).decode('utf-8')
|
|
|
|
|
|
|
|
def cipher_encode(thing):
|
|
|
|
padder=PKCS7(128).padder()
|
|
|
|
thong=padder.update(thing.encode('utf-8'))
|
|
|
|
thong+=padder.finalize()
|
|
|
|
key=b'0123456789012345'
|
|
|
|
coph=Cipher(algorithms.AES(key), modes.ECB(), backend=backend)
|
|
|
|
e=coph.encryptor()
|
|
|
|
out=e.update(thong)
|
|
|
|
out+=e.finalize()
|
|
|
|
return out
|