java中的aes加密算法如下:
public static byte[] decrypt(byte[] data, byte[] key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException { Security.addProvider(new BouncyCastleProvider()); Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding"); cipher.init(2, new SecretKeySpec(key, "AES")); return cipher.doFinal(data); } public static byte[] encrypt(byte[] data, byte[] key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException { Security.addProvider(new BouncyCastleProvider()); Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding"); cipher.init(1, new SecretKeySpec(key, "AES")); return cipher.doFinal(data); }
请问如何用php来实现
我测试了很多网上的例子都不能得到相同的密文
付费偷看金额在0.1-10元之间
一周热门 更多>