String.swap#

usencrypt.cipher.String.swap(condition: usencrypt.cipher._boolean.Boolean, s1, s2)#

Swaps two encrypted strings, \(E(x)\) and \(E(y)\), based on the given encrypted boolean condition.

Parameters
Returns

A tuple of encrypted strings that are swapped if condition is True.

Return type

A tuple of usencrypt.cipher.String objects.

Examples
>>> import usencrypt as ue
>>> ue_s1 = ue.encrypt('abc')
>>> ue_s2 = ue.encrypt('def')
>>> ue.decrypt(ue_s1.swap(1 == 1, ue_s1, ue_s2))
('def', 'abc')