admin 管理员组

文章数量: 887007

android 指纹存储密码,Android

在使用指纹扫描器进行用户身份验证之后,我需要加密不同的字符串和相关的解密.

private boolean tryEncrypt(Cipher cipher) {

try {

cipher.doFinal(SECRET_BYTES);

String one = "augusto";

String two = "test@gmail";

String three = "3333333331";

byte[] oneEnc = cipher.doFinal(one.getBytes());

byte[] twoEnc = cipher.doFinal(one.getBytes());

byte[] threeEnc = cipher.doFinal(one.getBytes());

Log.d("test", "oneEnc: " + Base64.encodeToString(oneEnc,0));

Log.d("test", "twoEnc: " + Base64.encodeToString(twoEnc,0));

Log.d("test", "threeEnc: " + Base64.encodeToString(threeEnc,0));

} catch (Exception e) {

e.printStackTrace();

return false;

}

return true;

}

我收到此错误:

java.lang.IllegalStateException: IV has already been used. Reusing IV in encryption mode violates security best practices.

正确的做法是什么?

谢谢

*******************更新:*****************************

为了帮助其他人解决此问题,我使用了这个库并像魅力一样工作:

本文标签: android 指纹存储密码 Android