JAVA AES 程式
public static String decryptWithBC(String data, String key) throws Exception {
ByteBuffer buffer = ByteBuffer.allocate(32);
buffer.put(key.getBytes());
KeyParameter kp = new KeyParameter(buffer.array());
byte[] bytes = Base64.decodeBase64(data);
CBCBlockCipher aes = new CBCBlockCipher(new AESEngine());
PKCS7Padding p7 = new PKCS7Padding();
PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(aes, p7);
cipher.init(false, kp);
byte[] output = new byte[cipher.getOutputSize(bytes.length)];
int len = cipher.processBytes(bytes, 0, bytes.length, output, 0);
int len2 = cipher.doFinal(output, len);
byte rawData[] = new byte[len+len2];
System.arraycopy(output, 0, rawData, 0, rawData.length);
String plainData = new String(rawData, Charset.forName("utf-8"));
return plainData;
}
這是aes/cbc/pkcs7daddping 256 嘛? 搞不懂它這個IV 填充方式,如何翻譯成php的 求大神幫忙
哪位幫解決,懸賞100
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/262123.html
標籤:其他
