Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android PublicKey to string

I am trying to convert PublicKey to String but I don't know how to do it properly. Following code doesn't give me correct key, so how convert it?

byte[] publicKeyBytes = userKeys.getPublic().getEncoded();
String pKstring = new String(publicKeyBytes);
like image 948
Blady214 Avatar asked Mar 15 '23 11:03

Blady214


1 Answers

I find out solution, below code is correct:

byte[] publicKeyBytes = Base64.encode(userKeys.getPublic().getEncoded(),0);
String pubKey = new String(publicKeyBytes);
like image 73
Blady214 Avatar answered Mar 23 '23 14:03

Blady214