java - Android Java:试图让这个 AES 加密库工作,但它没有
问题描述
我正在尝试测试这个库
http://blog.cwill-dev.com/2012/10/09/encryption-between-javaandroid-and-php/
使用此代码
ApiCrypter ApiCrypter = new ApiCrypter();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_profile);
try {
String encryptedRequest = ApiCrypter.bytesToHex(this.ApiCrypter.encrypt("hello world"));
Toast.makeText(this, encryptedRequest, Toast.LENGTH_LONG).show();
} catch (Exception e) {
e.printStackTrace();
}
在页面中提到的示例中
String encryptedRequest = ApiCrypter.bytesToHex(this.apiCrypter.encrypt(jsonParams.toString()));
但是“apiCrypter”不存在所以我使用了实例“ApiCrypter”
但是吐司根本没有被触发。我试图在 TextView 中显示该值,但它也是空的。请问有什么帮助吗?
解决方案
尝试更换:
ApiCrypter ApiCrypter = new ApiCrypter();
和:
ApiCrypter apiCrypter = new ApiCrypter();
接着:
String encryptedRequest = ApiCrypter.bytesToHex(this.apiCrypter.encrypt(jsonParams.toString()));
推荐阅读
- opencv - 在 Unity 中获得正确的位置
- python - 如何将字典的字符串值转换为布尔值?
- dafny - 在 Dafny 中用另一张地图更新地图
- ios - Xcode 10 - 构建项目失败
- angular - combineLatest 不会因为 behaviorSubject 而触发吗?
- c# - 带有 asp-route 参数的 cshtml 帖子
- android - 如何创建类似于 Google Play 电影部分的横向布局?
- angular - Ionic 在哪里为 app.html 中定义的按钮定义函数
- java - 仅用于目录路径的 URI?
- php - 从 s3 存储桶 php 中删除包含文件的文件夹