Ciphertext.encrypt_other#

usencrypt.cipher.Ciphertext.encrypt_other(self, x, mode='static', *args, **kwargs)#

Encrypts \(x\) dynamically with the same dtype as the encrypted object \(E(x)\). If \(x\) is already encrypted, then it serves as a fixed point.

Parameters
  • x (any supported encryptable type) – The value to be encrypted with the same dtype as self.

  • mode (str) – The mode of encryption. Defaults to 'static'.

Returns

The encrypted version of x, assuming that it is not already encrypted.

Return type

The same dtype as self.

Examples
>>> import usencrypt as ue
>>> ue_a = ue.encrypt(0.75)
>>> b = 2
>>> ue_b = ue_a.encrypt_other(b)
>>> ue_b
(0x7f845bf3ff70) Float: 0x9a0e9715c952fe72b530885e8bc047e6cf152492275d85d762bbdb900d60523c
>>> ue.decrypt(ue_b)
2.0