我已經通過身份驗證讓服務器訪問令牌"uyhjjfjfgg567f8fhjkkf"
,現在我想將其安全地保存在設備中。我在Android開發人員網站中查看了Keystore和Keychain。我不清楚它是如何工作的以及我們應該如何從密鑰庫中檢索令牌。如何在Android中安全地保存Oauth訪問令牌
KeyPairGenerator kpg = KeyPairGenerator.getInstance(
KeyProperties.KEY_ALGORITHM_EC, "AndroidKeyStore");
kpg.initialize(new KeyGenParameterSpec.Builder(
alias,
KeyProperties.PURPOSE_SIGN | KeyProperties.PURPOSE_VERIFY)
.setDigests(KeyProperties.DIGEST_SHA256,
KeyProperties.DIGEST_SHA512)
.build());
KeyPair kp = kpg.generateKeyPair();
/*
* Load the Android KeyStore instance using the the
* "AndroidKeyStore" provider to list out what entries are
* currently stored.
*/
KeyStore ks = KeyStore.getInstance("AndroidKeyStore");
ks.load(null);
Enumeration<String> aliases = ks.aliases();