优艾设计网

用php实现java中的aes加密?

优艾设计网 https://www.uibq.com 2023-05-23 07:57 出处:网络 作者:PS抠图
java中的aes加密算法如下: public static byte[] decrypt(byte[] data, byte[] key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeExcep

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 NoSuchPadd优艾设计网_在线设计ingException, 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

精彩评论

暂无评论...
验证码 换一张
取 消