我需要实现 256 位 AES 加密,我参考这个 - http://nelenkov.blogspot.jp/2015/06/keystore-redesign-in-android-m.html KeyGenerator 看起来像这样。
KeyGenerator keyGenerator = KeyGenerator
.getInstance(KeyProperties.KEY_ALGORITHM_AES,"AndroidKeyStore");
KeyGenParameterSpec spec = new KeyGenParameterSpec.Builder(keyName,
KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
.setUserAuthenticationValidityDurationSeconds(5 *11160)
.build();
keyGenerator.init(spec);
SecretKey key1 = keyGenerator.generateKey();
当我从密钥库导入密钥的编码值时,它返回 null 给我。
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
keyStore.load(null);
SecretKey key3 = (SecretKey) keyStore.getKey(keyName, null);
Log.d("Test MM",key3.getEncoded()+",");
我在 logcat 中找到了 key3.getEncoded() 的空值。请给我一些建议。