base64 和aes-128-ecb都可以使用这个jar包中的方式去加密和解密
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.60</version>
</dependency>
<dependency>
<groupId>com.hikvision.bigdata.shield</groupId>
<artifactId>crypto-util</artifactId>
<version>1.0.0</version>
</dependency>
public class AESUtils {
public static final String KEY = "Rsh@idatalight"; // 秘钥key
/**
* create by: tanjian8
* description: aes加密方法
* create time: 2022/05/27 10:19
*/
public static String aesEncrypt(String content){
try {
return AES_ECB_Encrypt(content, KEY, 128, "null");
}catch (Exception e){
e.printStackTrace();
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "AES加密失败" + e.toString());
}
}
/**
* create by: tanjian8
* description: aes解密方法
* create time: 2022/05/27 10:19
*/
public static String aesDecrypt(String content){
try {
return AES_ECB_Decrypt(content, KEY, 128, "null");
}catch (Exception e){
e.printStackTrace();
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "AES解密失败" + e.toString());
}
}
/**
* create by: tanjian8
* description: base64加密方法
* create time: 2022/05/27 10:19
*/
public static String base64Encrypt(String content) {
try {
return Base64_Encode(content);
}catch (Exception e){
e.printStackTrace();
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "base64加密失败" + e.toString());
}
}
/**
* create by: tanjian8
* description: base64解密方法
* create time: 2022/05/27 10:19
*/
public static String base64Dncrypt(String content) {
try {
return Base64_Decode(content);
}catch (Exception e){
e.printStackTrace();
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "base64解密失败" + e.toString());
}
}
}