import secrets import struct from cryptography.hazmat.primitives import padding from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes def as_signed(val: int): # converts an integer to a signed int return struct.unpack('