10
10
from uuid import uuid4
11
11
12
12
import requests
13
- from Crypto .Cipher import AES
14
13
15
14
URL = 'https://feelinsonice-hrd.appspot.com/bq/'
15
+ from cryptography .hazmat .primitives .ciphers import Cipher , algorithms , modes
16
+ from cryptography .hazmat .backends import default_backend
16
17
17
18
SECRET = b'iEk21fuwZApXlz93750dmW22pw389dPwOk'
18
19
STATIC_TOKEN = 'm198sOkJEn37DjqZ32lpRu76xmw288xSQ9'
@@ -38,18 +39,24 @@ def pkcs5_pad(data, blocksize=16):
38
39
39
40
40
41
def decrypt (data ):
41
- cipher = AES .new (BLOB_ENCRYPTION_KEY , AES .MODE_ECB )
42
- return cipher .decrypt (pkcs5_pad (data ))
42
+ cipher = Cipher (algorithms .AES (BLOB_ENCRYPTION_KEY ), modes .ECB (),
43
+ backend = default_backend ())
44
+ decryptor = cipher .decryptor ()
45
+ return decryptor .update (pkcs5_pad (data )) + decryptor .finalize ()
43
46
44
47
45
48
def decrypt_story (data , key , iv ):
46
- cipher = AES .new (key , AES .MODE_CBC , iv )
47
- return cipher .decrypt (pkcs5_pad (data ))
49
+ cipher = Cipher (algorithms .AES (key ), modes .CBC (iv ),
50
+ backend = default_backend ())
51
+ decryptor = cipher .decryptor ()
52
+ return decryptor .update (pkcs5_pad (data )) + decryptor .finalize ()
48
53
49
54
50
55
def encrypt (data ):
51
- cipher = AES .new (BLOB_ENCRYPTION_KEY , AES .MODE_ECB )
52
- return cipher .encrypt (pkcs5_pad (data ))
56
+ cipher = Cipher (algorithms .AES (BLOB_ENCRYPTION_KEY ), modes .ECB (),
57
+ backend = default_backend ())
58
+ encryptor = cipher .encryptor ()
59
+ return encryptor .update (pkcs5_pad (data )) + encryptor .finalize ()
53
60
54
61
55
62
def timestamp ():
0 commit comments