You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Custom Base64EncodingTextEncryptor not possible for Encryptors.queryableText()Β #5099
When the user wants to store an encrypted text in the database (in text, not binary format) using the available TextEncryptor (for example through Encryptors.delux()), the resultant String is hex-encoded (through HexEncodingTextEncryptor).
Hex-encoding is very inefficient when it comes to size. So the user writes his own Base64EncodingTextEncryptor to use it instead of HexEncodingTextEncryptor, as the Base64 is much more efficient.
It's easy to use such a Base64EncodingTextEncryptor to wrap the default Encryptors methods, like the Encryptor.stronger(). But it's not easily possible (AFAIK) to use the Base64 encoding to wrap a Encryptors.queryableText() method (because it already returns a hex-encoded string, unless we decode the hex-encoded string to encode it again in Base64, which is not the best option).
The problem:
there is no possibility to use a TextEncryptor other than HexEncodingTextEncryptor for the "queryable" texts (that is, texts encrypted with empty iv).
"queryable" text functionality justifies the empty iv (when it's really needed).
Possible solutions:
public AesBytesEncryptor (so we can wrap it with custom TextEncryptor - when using empty iv)
something like noIvText method in Encryptors (so we can wrap an Encryptors empty iv method with custom TextEncryptor)
Having an additional queryable method which returns a BytesEncryptor, the user can wrap it in any custom TextEncryptor he wants - he's no longer limited to HexEncodingTextEncryptor.
Activity
ksdev-pl commentedon Mar 10, 2018
Another simple solution:
Having an additional
queryablemethod which returns aBytesEncryptor, the user can wrap it in any customTextEncryptorhe wants - he's no longer limited toHexEncodingTextEncryptor.AesBytesEncryptorTests
AesBytesEncryptorTests
Make AesByesEncryptor public