Reputation: 739
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);
Upvotes: 4
Views: 3354
Reputation: 739
I find out solution, below code is correct:
byte[] publicKeyBytes = Base64.encode(userKeys.getPublic().getEncoded(),0);
String pubKey = new String(publicKeyBytes);
Upvotes: 7