Android在密钥库中存储byte [] [英] Android store byte[] in the keystore
本文介绍了Android在密钥库中存储byte []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对密钥库非常困惑. 我发现了很多关于它的线索,但是没有任何用.我想在密钥库中存储和加载指定的密钥(byte []且未生成). 那行吗?我尝试了很多,但没有任何效果.
I'm very confused about the keystore. I found a lot threads about it but nothing works. I want to store and load a specified key (byte[] and not generated) in the keystore. Is that working? I tried a lot but nothing works.
您有一些代码片段吗?
Do you have some codesnippets?
谢谢 朱尔斯
KeyStore ks = KeyStore.getInstance("AndroidKeyStore");
ks.load(null);
ks.setEntry(alias, entry, param);
OutputStream writeStream = new FileOutputStream(path);
ks.store(writeStream, passwordForKey);
writeStream.close();
推荐答案
您必须使用Bas64编码(Android.util.Base64)将其存储为字符串. 没有存储原始字节数组的功能
You have to use Bas64-Encoding (Android.util.Base64) to store it as a string. There is no function to store a raw byte-Array
这篇关于Android在密钥库中存储byte []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文