Boolean#
- class usencrypt.cipher.Boolean(value=None, *args, **kwargs)#
Ciphertext logical variable, stored as a 64-bit boolean.
- Parameters
value (
bool
) – The boolean to be encrypted. Defaults toNone
.hexstr (
str
) – The hexadecimal representation of the encrypted boolean object. Defaults toNone
.
Note
63 of the 64 bits are filled with rubbish.
The value is represented as type
b64
, and it should be a boolean, a bit, or an instance ofusencrypt.cipher.Boolean
itself or its internal storage type. In those last cases, it’s returned unchanged.Further, type conversion is performed on \(\{0, 1\}\), but not on
None
.
See also
- Examples
To create an encrypted boolean object from a non-encrypted boolean, we can do the following:
>>> import usencrypt as ue >>> ue_x = ue.cipher.Boolean(value=True) >>> ue_x (0x7f843a4af730) Boolean: 0xc9b43bd13c6aba5c49c433007e42b001e249fd569be54bcb119239c1d54d08a8 >>> ue.decrypt(ue_x) True
Similarly, we can encrypt a non-encrypted boolean directly using the
usencrypt.encrypt()
function:>>> import usencrypt as ue >>> ue_x = ue.encrypt(True, dtype=bool) >>> ue_x (0x7f843a4af730) Boolean: 0xc9b43bd13c6aba5c49c433007e42b001e249fd569be54bcb119239c1d54d08a8 >>> ue.decrypt(ue_x) True
Finally, we can also create an encrypted boolean object directly from a hexadecimal string:
>>> import usencrypt as ue >>> ue_x = ue.cipher.Boolean(hexstr='0xc9b43bd13c6aba5c49c433007e42b001e249fd569be54bcb119239c1d54d08a8') >>> ue_x (0x7f843a4af730) Boolean: 0xc9b43bd13c6aba5c49c433007e42b001e249fd569be54bcb119239c1d54d08a8 >>> ue.decrypt(ue_x) True
METHODS
Decrypts the encrypted object \(E(x)\), returning the original non-encrypted \(x\). |
|
Encrypts \(x\) dynamically with the same |