Skip to content

Instantly share code, notes, and snippets.

public class AESCryptoUtil {
private static final String KEY_SPEC_AES = "AES";
public static final String CHARSET_NAME = "UTF-8";
public static final String SHA_1 = "SHA-1";
private static final String CIPHER = "AES/CBC/PKCS5Padding";
public byte[] encrypt(final byte[] data, final String keyString) throws Exception {
return encrypt(data, keyString.getBytes(CHARSET_NAME));
}
// Decrypt the decryption key
final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
sdf.setTimeZone(TimeZone.getTimeZone("utc"));
final String rawDecryptor =
sdf.format(content.getDue()) + service.getPatron().getId().toString()
+ content.getCircId().toString();
final byte[] decryptor = aesCryptoUtil.createHash(rawDecryptor.getBytes());
final byte[] decryptionKey =
aesCryptoUtil.decrypt(