Skip to content
Advertisement

how to construct a java.security.interfaces.RSAPublicKey?

I have the following string, which I understand to be an RSA public key:

JavaScript

I need to construct a java.security.interfaces.RSAPublicKey from this string. First I tried calling RSAPublicKeyImpl.newKey(myString.getBytes(StandardCharsets.UTF_8)), but that threw the following exception:

JavaScript

Then, following an online guide, I tried this code instead:

JavaScript

That threw a very similar exception, just wrapped in another one.

Am I missing something obvious here? How do I construct a RSAPublicKey?

Advertisement

Answer

this method can help you

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement