-
-
Save ryctabo/ff8aa39080c049ea471a6e3ec5e8f260 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read all bytes from the public key file | |
Path path = Paths.get(publicKeyFile); | |
byte[] bytes = Files.readAllBytes(path); | |
KeyFactory keyFactory = KeyFactory.getInstance("RSA"); | |
// Generate the public key object from bytes | |
X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(bytes); | |
PublicKey publicKey = keyFactory.generatePublic(publicKeySpec); | |
// Print public key format | |
LOG.info(String.format("Public key format: %s", publicKey.getFormat())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment