code: private PublicKey getPemPublicKey(final String keyString) throws EncryptionException {
        try {
           final String publicKeyPEM = keyString.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "").replaceAll("\\v", "");
  
           final Base64 b64 = new Base64();
           final byte[] decoded = b64.decode(publicKeyPEM);
  
           final X509EncodedKeySpec spec = new X509EncodedKeySpec(decoded);
           final KeyFactory kf = KeyFactory.getInstance(ALGORITHM);
  
           return kf.generatePublic(spec);
        } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
           throw new EncryptionException("Unable to obtain public key: ", e);
        }
     }
docs: Initializes a public key from a string.
  
  @param keyString
  String representation of the key.
  @return An initialized public key.
  @throws EncryptionException
  When it was not possible to initialize the key.