Skip to content

Instantly share code, notes, and snippets.

@yayj
Created August 9, 2013 08:02
Show Gist options
  • Save yayj/6191911 to your computer and use it in GitHub Desktop.
Save yayj/6191911 to your computer and use it in GitHub Desktop.
encrypte
String salt = DigestUtils.md5Hex("linkmatic");
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding", "SunJCE");
cipher.init(Cipher.ENCRYPT_MODE,
new SecretKeySpec(salt.getBytes(), "AES"),
new IvParameterSpec(DigestUtils.md5Hex(salt).substring(0, 16).getBytes()));
byte[] bytes = src.getBytes("UTF-8");
return new String(Base64.encodeBase64(cipher.doFinal(bytes)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment