public static void main(String[] args) {
try {
SecretKey key = KeyGenerator.getInstance("AES").generateKey();
Cipher aes = Cipher.getInstance("AES");
HexDumpEncoder enc = new HexDumpEncoder();
byte[] text = "暗号化テスト".getBytes();
System.out.println(enc.encode(text));
// 暗号化
aes.init(Cipher.ENCRYPT_MODE, key);
byte[] encryptText = aes.doFinal(text);
System.out.println(enc.encode(encryptText));
// 複合化
aes.init(Cipher.DECRYPT_MODE, key);
byte[] decryptText = aes.doFinal(encryptText);
System.out.println(enc.encode(decryptText));
} catch (Exception e) {
e.printStackTrace();
}
}