示例代码:
byte[] keyBytes = new byte[32]; String keyString = "1234567890123456"; System.arraycopy(keyString.getBytes(), 0, keyBytes, 0, keyString.getBytes().length); SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, "AES");
示例代码:
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); IvParameterSpec ivParams = new IvParameterSpec(new byte[16]); cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParams);
示例代码:
byte[] cipherBytes = Base64.decodeBase64(cipherText); byte[] plaintextBytes = cipher.doFinal(cipherBytes); String plaintext = new String(plaintextBytes); System.out.println("解密后的明文:" + plaintext);
上一篇:AES-256加密/解密
下一篇:AES-256密码解密