|
@@ -4,6 +4,7 @@ package edu.nju.util;
|
|
import javax.crypto.Cipher;
|
|
import javax.crypto.Cipher;
|
|
import javax.crypto.spec.IvParameterSpec;
|
|
import javax.crypto.spec.IvParameterSpec;
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
|
|
+import java.net.URLEncoder;
|
|
import java.util.Base64;
|
|
import java.util.Base64;
|
|
|
|
|
|
public class AESUtil {
|
|
public class AESUtil {
|
|
@@ -23,7 +24,8 @@ public class AESUtil {
|
|
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec);
|
|
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec);
|
|
bytes = cipher.doFinal(bytes);
|
|
bytes = cipher.doFinal(bytes);
|
|
bytes = Base64.getEncoder().encode(bytes);
|
|
bytes = Base64.getEncoder().encode(bytes);
|
|
- return new String(bytes);
|
|
|
|
|
|
+ String res = new String(bytes);
|
|
|
|
+ return URLEncoder.encode(res);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
return null;
|
|
return null;
|