This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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( |