Jasypt provides several easy encryption tools. These are classes which allow (with little or no configuration, and with no need of knowing what is happening "behind the scenes") the execution of some of the most common encryption tasks.
Thses tools are categorized depending on the task they are intended to do:
...
Digester digester = new Digester();
digester.setAlgorithm("SHA-1");
...
byte[] digest = digester.digest(message);
...
All classes here implement the org.jasypt.util.password.PasswordEncryptor interface, so that they can be used interchangeabily if needed.
...
BasicPasswordEncryptor passwordEncryptor = new BasicPasswordEncryptor();
String encryptedPassword = passwordEncryptor.encryptPassword(userPassword);
...
if (passwordEncryptor.checkPassword(inputPassword, encryptedPassword)) {
// correct!
} else {
// bad login!
}
...
...
StrongPasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();
String encryptedPassword = passwordEncryptor.encryptPassword(userPassword);
...
if (passwordEncryptor.checkPassword(inputPassword, encryptedPassword)) {
// correct!
} else {
// bad login!
}
...
...
ConfigurablePasswordEncryptor passwordEncryptor = new ConfigurablePasswordEncryptor();
passwordEncryptor.setAlgorithm("SHA-1");
passwordEncryptor.setPlainDigest(true);
String encryptedPassword = passwordEncryptor.encryptPassword(userPassword);
...
if (passwordEncryptor.checkPassword(inputPassword, encryptedPassword)) {
// correct!
} else {
// bad login!
}
...
All classes here implement the org.jasypt.util.text.TextEncryptor interface, so that they can be used interchangeabily if needed.
... BasicTextEncryptor textEncryptor = new BasicTextEncryptor(); textEncryptor.setPassword(myEncryptionPassword); ... String myEncryptedText = textEncryptor.encrypt(myText); ... String plainText = textEncryptor.decrypt(myEncryptedText); ...
... StrongTextEncryptor textEncryptor = new StrongTextEncryptor(); textEncryptor.setPassword(myEncryptionPassword); ... String myEncryptedText = textEncryptor.encrypt(myText); ... String plainText = textEncryptor.decrypt(myEncryptedText); ...
All classes here implement either the org.jasypt.util.numeric.DecimalNumberEncryptor or the org.jasypt.util.numeric.IntegerNumberEncryptor interfaces, so that they can be used interchangeabily if needed.
... BasicIntegerNumberEncryptor integerEncryptor = new BasicIntegerNumberEncryptor(); integerEncryptor.setPassword(myEncryptionPassword); ... BigInteger myEncryptedNumber = textEncryptor.encrypt(myNumber); ... BigInteger plainNumber = textEncryptor.decrypt(myEncryptedNumber); ...
... StrongIntegerNumberEncryptor integerEncryptor = new StrongIntegerNumberEncryptor(); integerEncryptor.setPassword(myEncryptionPassword); ... BigInteger myEncryptedNumber = integerEncryptor.encrypt(myNumber); ... BigInteger plainNumber = integerEncryptor.decrypt(myEncryptedNumber); ...
... BasicIntegerNumberEncryptor decimalEncryptor = new BasicIntegerNumberEncryptor(); decimalEncryptor.setPassword(myEncryptionPassword); ... BigDecimal myEncryptedNumber = decimalEncryptor.encrypt(myNumber); ... BigDecimal plainNumber = decimalEncryptor.decrypt(myEncryptedNumber); ...
... StrongDecimalNumberEncryptor decimalEncryptor = new StrongDecimalNumberEncryptor(); decimalEncryptor.setPassword(myEncryptionPassword); ... BigDecimal myEncryptedNumber = decimalEncryptor.encrypt(myNumber); ... BigDecimal plainNumber = decimalEncryptor.decrypt(myEncryptedNumber); ...
All classes here implement the org.jasypt.util.binary.BinaryEncryptor interface, so that they can be used interchangeabily if needed.
... BasicBinaryEncryptor binaryEncryptor = new BasicBinaryEncryptor(); binaryEncryptor.setPassword(myEncryptionPassword); ... byte[] myEncryptedBinary = binaryEncryptor.encrypt(myBinary); ... String plainBinary = binaryEncryptor.decrypt(myEncryptedBinary); ...
... StrongBinaryEncryptor binaryEncryptor = new StrongBinaryEncryptor(); binaryEncryptor.setPassword(myEncryptionPassword); ... String myEncryptedBinary = binaryEncryptor.encrypt(myBinary); ... String plainBinary = binaryEncryptor.decrypt(myEncryptedBinary); ...