Skip to content

Instantly share code, notes, and snippets.

@md-5
Created July 22, 2012 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save md-5/3157653 to your computer and use it in GitHub Desktop.
Save md-5/3157653 to your computer and use it in GitHub Desktop.
Shared key
private static byte[] getShared(SecretKey key, PublicKey pubkey) {
try {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, pubkey);
return cipher.doFinal(key.getEncoded());
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment