Android store byte[] in the keystore

淺唱寂寞╮ 提交于 2019-12-08 10:34:26

问题


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?

THANKS Jules

Edit:

KeyStore ks = KeyStore.getInstance("AndroidKeyStore");
ks.load(null);
ks.setEntry(alias, entry, param);
OutputStream writeStream = new FileOutputStream(path);
ks.store(writeStream, passwordForKey);
writeStream.close();

回答1:


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



来源:https://stackoverflow.com/questions/26753025/android-store-byte-in-the-keystore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!