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