Int#
- class usencrypt.cipher.Int(value=None, *args, **kwargs)#
Ciphertext integer variable, stored as a 64-bit signed integer.
- Parameters
value (
int
) – The integer to be encrypted. Defaults toNone
.hexstr (
str
) – The hexadecimal representation of the encrypted integer object. Defaults toNone
.
See also
- Examples
To create an encrypted integer object from a non-encrypted integer, we can do the following:
>>> import usencrypt as ue >>> ue_x = ue.cipher.Int(value=2) >>> ue_x (0x7f845beec7f0) Int: 0x58c6ebef2887766f5ac857cbf1f4c2e75817fc4b4efa1682661ac391545af88f >>> ue.decrypt(ue_x) 2
Similarly, we can encrypt a non-encrypted integer directly using the
usencrypt.encrypt()
function:>>> import usencrypt as ue >>> ue_x = ue.encrypt(2, dtype=int) >>> ue_x (0x7f845beec7f0) Int: 0x58c6ebef2887766f5ac857cbf1f4c2e75817fc4b4efa1682661ac391545af88f >>> ue.decrypt(ue_x) 2
Finally, we can also create an encrypted integer object directly from a hexadecimal string:
>>> import usencrypt as ue >>> ue_x = ue.cipher.Int(hexstr='0x58c6ebef2887766f5ac857cbf1f4c2e75817fc4b4efa1682661ac391545af88f') >>> ue_x (0x7f845beec7f0) Int: 0x58c6ebef2887766f5ac857cbf1f4c2e75817fc4b4efa1682661ac391545af88f >>> ue.decrypt(ue_x) 2
METHODS
Decrypts the encrypted object \(E(x)\), returning the original non-encrypted \(x\). |
|
Encrypts \(x\) dynamically with the same |