forked from eclipse/paho.mqtt.python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui5.py
34 lines (21 loc) · 1.12 KB
/
gui5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from binascii import unhexlify
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import padding as padding2
from cryptography.hazmat.backends import default_backend
choiceToken = "4a4b5869679c8ce2049ee8a33c2217b0"
choiceByte = unhexlify(choiceToken)
value = b'merhaba'
backend = default_backend()
encryptor = Cipher(algorithms.AES(choiceByte), modes.ECB(), backend).encryptor()
padder = padding2.PKCS7(algorithms.AES(choiceByte).block_size).padder()
padded_data = padder.update(value) + padder.finalize()
encrypted_message = encryptor.update(padded_data) + encryptor.finalize()
backend = default_backend()
decryptor = Cipher(algorithms.AES(choiceByte), modes.ECB(), backend).decryptor()
padder = padding2.PKCS7(algorithms.AES(choiceByte).block_size).unpadder()
decrypted_data = decryptor.update(encrypted_message)
decrypted_payload = padder.update(decrypted_data) + padder.finalize()
print(decrypted_payload)
payload = b'index::::index2::::'
payload2 = payload[0: len(payload)-4]
print(payload2)