// Declare a basic encryptor
BasicTextEncryptor te = new BasicTextEncryptor();
// Set password to use
te.setPassword(PASSWORD_FOR_ENCRYPTION);
// Encrypt text. By default the algorithm used is PBEWithMD5AndDES
String encryptedText = te.encrypt(TEXT_TO_ENCRYPT);
System.out.printf("testTextEncryptionUsingBasicTextEncryptor : '%s' become '%s'\n", TEXT_TO_ENCRYPT, encryptedText);
// Valid "encrypted" text
Assert.assertEquals(te.decrypt(encryptedText), TEXT_TO_ENCRYPT);
}