Android store byte[] in the keystore

2019-06-09 16:01发布

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条回答
叼着烟拽天下
2楼-- · 2019-06-09 16:31

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

查看更多
登录 后发表回答