其他分享
首页 > 其他分享> > Android PublicKey为字符串

Android PublicKey为字符串

作者:互联网

我试图将PublicKey转换为String但我不知道如何正确地执行它.下面的代码没有给我正确的密钥,那么如何转换呢?

byte[] publicKeyBytes = userKeys.getPublic().getEncoded();
String pKstring = new String(publicKeyBytes);

解决方法:

我找到解决方案,下面的代码是正确的:

byte[] publicKeyBytes = Base64.encode(userKeys.getPublic().getEncoded(),0);
String pubKey = new String(publicKeyBytes);

标签:android,type-conversion,public-key
来源: https://codeday.me/bug/20190829/1762675.html