Skip to content

Instantly share code, notes, and snippets.

@knitfaced
Created November 11, 2010 21:37
Show Gist options
  • Save knitfaced/673243 to your computer and use it in GitHub Desktop.
Save knitfaced/673243 to your computer and use it in GitHub Desktop.
private String encryptCredentials(String plaintext) throws Exception {
String algorithm = "AES/CBC/PKCS5Padding";
SecretKeySpec skeySpec = new SecretKeySpec(SECRET_KEY.getBytes(), algorithm);
Cipher cipher = Cipher.getInstance(algorithm);
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted = cipher.doFinal(plaintext.getBytes());
return new String(encrypted);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment