Skip to content

Instantly share code, notes, and snippets.

@diaolizhi
Created April 10, 2019 10:53
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 diaolizhi/a3a55108757fffa6da4d032e66d1d735 to your computer and use it in GitHub Desktop.
Save diaolizhi/a3a55108757fffa6da4d032e66d1d735 to your computer and use it in GitHub Desktop.
AES 解密
public static String decrypt(String encrypted) {
String KEY = ")O[NB]6,YF}+efcaj{+oESb9d8>Z'e9M";
String IV = "L+\\~f4,Ir)b$=pkf";
try {
IvParameterSpec iv = new IvParameterSpec(IV.getBytes("UTF-8"));
SecretKeySpec skeySpec = new SecretKeySpec(KEY.getBytes("UTF-8"), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
byte[] original = cipher.doFinal(Base64.decode(encrypted));
return new String(original);
} 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