[英]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.