AES加解密在Android 4.2上的Encryption error

只需通过判断SDK版本后进行特定初始化操作即可:

private final static int JELLY_BEAN_4_2 = 17;	

SecureRandom sr = null;
if (android.os.Build.VERSION.SDK_INT >=  JELLY_BEAN_4_2) {
	sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");
} else {
	sr = SecureRandom.getInstance("SHA1PRNG");
}

 

参考文档:

http://stackoverflow.com/questions/13389870/android-4-2-broke-my-aes-encrypt-decrypt-code

 

相关参考:

1.【工具类】AES加密和解密

2.【工具类】Android数据存储sharedpreferences加密


 

你可能感兴趣的:(android,加密,解密)