android - 密码函数:OPENSSL_internal:BAD_DECRYPT in android Oreo
问题描述
Android Oreo 版本 8 在生产中引发错误的解密错误。对于其他 android 版本的代码工作正常。使用的算法是“AES/CBC/PKCS5Padding”。
public String decrypt(String _encryptedText, String _key, String _iv)
throws InvalidKeyException, UnsupportedEncodingException,
InvalidAlgorithmParameterException, IllegalBlockSizeException,
BadPaddingException {
//Log.d("enetered decryption", "enetered decryption");
return encryptDecrypt(_encryptedText, _key, EncryptMode.DECRYPT, _iv);
}
public String decryptionflag(String input, String iv) {
String output = "";
try {
// CryptLib _crypt = new CryptLib();
String plainText = input;
CryptLib _crypt = new CryptLib();
output = _crypt.decrypt(plainText, key, iv); // decrypt
//Log.d("decrypted flag is", "" + output);
} catch (InvalidAlgorithmParameterException e) {
// TODO Auto-generated catch block
Log.e("", "Exception" + e.getMessage());
} catch (InvalidKeyException e){
Log.e("", "Exception" + e.getMessage());
} catch (UnsupportedEncodingException e){
Log.e("", "Exception" + e.getMessage());
} catch (BadPaddingException e){
Log.e("", "Exception" + e.getMessage());
} catch (IllegalBlockSizeException e){
Log.e("", "Exception" + e.getMessage());
} catch (NoSuchAlgorithmException e){
Log.e("", "Exception" + e.getMessage());
} catch (NoSuchPaddingException e){
Log.e("", "Exception" + e.getMessage());
}
return output;
}
用于加密和解密的密钥是相同的。并且此代码适用于 UAT(android oreo 版本),但生产时出错。
解决方案
推荐阅读
- gstreamer - GStreamer 视频流性能低下
- google-crawlers - 我们如何告诉 Google 的爬虫在其移动可用性分析中忽略所有具有特定 URL 变量的页面?
- angular - ASP.Net Core 2.2 和 Angular 7+ 应用程序的身份验证
- javascript - Microsoft Dynamics CRM 中来自 Web API 的查找字段格式化值未定义(无法获取格式化值)
- android - 基于旧应用创建新的 Android 应用
- python - 如何使用引导模式在 Django 中使用基于类的视图删除对象?
- r - 计算并将值添加到数据框
- django - 将初始值传递给使用 TinyMCE 小部件的表单 CharField 时,“CharField”对象没有属性“is_hidden”
- dynamics-crm - 使用从 Dynamics CRM 中的相关实体查找的值填充文档模板
- reactjs - 循环通过 mapbox getDirections 来填充路由数组