我想将私钥存储在android KeyChain中。我已经写了代码来存储密钥。但是我不知道何时卸载应用程序并清除应用程序密钥丢失与否。当清除应用程序或卸载密钥仍然存在时,我想将密钥存储在KeyChain中。
try {
Intent intent = KeyChain.createInstallIntent();
intent.putExtra("PKEY", privateKey);
intent.putExtra("KEY", publicKey);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
return true;
} catch (ActivityNotFoundException e) {
Log.w("MainActivity", "could not store key pair: " + e);
}
如何从KeyChain.createInstallIntent()中检索私钥?
答案 0 :(得分:2)
意图仅在有限的时间内存储数据。如果您想永久存储键值数据,我建议使用Json Api。您必须使用PHP创建json API,并在需要时通过调用APi来管理数据应用程序。