Created
April 10, 2019 10:53
-
-
Save diaolizhi/a3a55108757fffa6da4d032e66d1d735 to your computer and use it in GitHub Desktop.
AES 解密
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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