Skip to content

Instantly share code, notes, and snippets.

@lkdocs
Created September 11, 2013 17:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lkdocs/6526781 to your computer and use it in GitHub Desktop.
Save lkdocs/6526781 to your computer and use it in GitHub Desktop.
public static byte[] decryptWithPrivateKey(byte[] message, String privateKey) throws Exception {
PrivateKey pKey = getRSAPrivateKeyFromString(privateKey);
Cipher rsaCipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA1AndMGF1Padding", "SC");
rsaCipher.init(Cipher.DECRYPT_MODE, pKey);
return rsaCipher.doFinal(message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment