[英]how to openssl_decrypt in android?
我有代码$value = openssl_encrypt($value, "AES-258", "123456789012acsdzxcsdweasd", 0, $123456789012345);
在我的PHP中。 然后$ value使用json_encoded传递。
现在,我想使用openssl_decrypt在android中解密该$ value,但没有人为其构建库。 如何以简单的方式做到这一点?
您可以尝试以下方法:
public class DecryptUtils{
public static String AES ( byte [] cipherText, String encryptionKey )
{
String decrypted = null;
try
{
Cipher cipher = Cipher.getInstance ( "AES");
SecretKeySpec key = new SecretKeySpec ( encryptionKey.getBytes ( "UTF-8" ), "AES" );
cipher.init ( Cipher.DECRYPT_MODE, key);
decrypted = new String ( cipher.doFinal ( cipherText ), "UTF-8" );a
}
catch ( Exception e )
{
e.printStackTrace()
}
return decrypted;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.