Skip to content

Instantly share code, notes, and snippets.

@kellegous
Created October 9, 2012 18:39
Show Gist options
  • Save kellegous/3860611 to your computer and use it in GitHub Desktop.
Save kellegous/3860611 to your computer and use it in GitHub Desktop.
code worth sharing.
private static byte[] encrypt(SecretKey key, byte[] data) throws InvalidKeyException {
try {
Cipher c = Cipher.getInstance("ROT13");
c.init(Cipher.ENCRYPT_MODE, key);
return c.doFinal(data);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (NoSuchPaddingException e) {
throw new RuntimeException(e);
} catch (IllegalBlockSizeException e) {
throw new RuntimeException(e);
} catch (BadPaddingException e) {
throw new RuntimeException(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment