Jasypt offers support for performing PBE (Password Based Encryption) operations on numbers. This is offered through the org.jasypt.encryption.pbe.PBEBigIntegerEncryptor and org.jasypt.encryption.pbe.PBEBigDecimalEncryptor interfaces and their respective default implementations, org.jasypt.encryption.pbe.StandardPBEBigIntegerEncryptor and org.jasypt.encryption.pbe.StandardPBEBigDecimalEncryptor.
Jasypt uses the byte (binary) encryption mechanisms as a basis for text encryption.
Note that encrypted numbers will need much more digits for its representation than the original numbers from which they come, and so they will also need more space for being stored. For example, a 4-byte integer will probably have a size of no less than 16 bytes, once encrypted. This is why only BigIntegers and BigDecimals can be encrypted with jasypt, and not usual integers, longs, floats... (although these can be encrypted in hibernate as Strings instead of numbers) .
Assuming that you will be using the default implementations, once a StandardPBEBigIntegerEncryptor or StandardPBEBigDecimalEncryptor instance has been created, this is how it will work:
The algorithm, password and key-obtention iterations can take values in any of these ways:
And the actual values to be used for initialization will be established by applying the following priorities:
Before it is ready to encrypt, an object of this class has to be initialized. Initialization happens:
An encryptor may be used for:
When using a random salt generator, two encryption results for the same message will always be different (except in the case of random salt coincidence). This enforces security by difficulting brute force attacks on sets of data at a time and forcing attackers to perform a brute force attack on each separate piece of encrypted data.
To learn more about the mechanisms involved in encryption, read PKCS #5: Password-Based Cryptography Standard.