1. base64 aes-128-ecb都可以使用这个jar包中的方式去加密和解密
    2. <dependency>
    3. <groupId>org.bouncycastle</groupId>
    4. <artifactId>bcprov-jdk15on</artifactId>
    5. <version>1.60</version>
    6. </dependency>
    7. <dependency>
    8. <groupId>com.hikvision.bigdata.shield</groupId>
    9. <artifactId>crypto-util</artifactId>
    10. <version>1.0.0</version>
    11. </dependency>
    12. public class AESUtils {
    13. public static final String KEY = "Rsh@idatalight"; // 秘钥key
    14. /**
    15. * create by: tanjian8
    16. * description: aes加密方法
    17. * create time: 2022/05/27 10:19
    18. */
    19. public static String aesEncrypt(String content){
    20. try {
    21. return AES_ECB_Encrypt(content, KEY, 128, "null");
    22. }catch (Exception e){
    23. e.printStackTrace();
    24. throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "AES加密失败" + e.toString());
    25. }
    26. }
    27. /**
    28. * create by: tanjian8
    29. * description: aes解密方法
    30. * create time: 2022/05/27 10:19
    31. */
    32. public static String aesDecrypt(String content){
    33. try {
    34. return AES_ECB_Decrypt(content, KEY, 128, "null");
    35. }catch (Exception e){
    36. e.printStackTrace();
    37. throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "AES解密失败" + e.toString());
    38. }
    39. }
    40. /**
    41. * create by: tanjian8
    42. * description: base64加密方法
    43. * create time: 2022/05/27 10:19
    44. */
    45. public static String base64Encrypt(String content) {
    46. try {
    47. return Base64_Encode(content);
    48. }catch (Exception e){
    49. e.printStackTrace();
    50. throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "base64加密失败" + e.toString());
    51. }
    52. }
    53. /**
    54. * create by: tanjian8
    55. * description: base64解密方法
    56. * create time: 2022/05/27 10:19
    57. */
    58. public static String base64Dncrypt(String content) {
    59. try {
    60. return Base64_Decode(content);
    61. }catch (Exception e){
    62. e.printStackTrace();
    63. throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "base64解密失败" + e.toString());
    64. }
    65. }
    66. }