From f36821f2611e7bac0692572c02e474aec6d258fb Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期五, 28 一月 2022 16:41:13 +0800 Subject: [PATCH] Mysql数据库AES加密工具 --- src/main/java/com/hx/util/SimpleEncrypt.java | 17 ++++------------- 1 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/hx/util/SimpleEncrypt.java b/src/main/java/com/hx/util/SimpleEncrypt.java index 69909b0..88f48a2 100644 --- a/src/main/java/com/hx/util/SimpleEncrypt.java +++ b/src/main/java/com/hx/util/SimpleEncrypt.java @@ -1,12 +1,6 @@ package com.hx.util; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Random; - -import sun.misc.BASE64Decoder; -import sun.misc.BASE64Encoder; +import java.util.*; /*** * 锟�?鍗曠殑鍔犲瘑绋嬪簭锛屽拰瑙e瘑绋嬪簭 @@ -54,11 +48,7 @@ public static String simpleEnCode(String dataString) { // 缁勬嫾闅忔満鍊� String ranString = generateCheckCode(13).toString() + dataString + generateCheckCode(9).toString(); - - System.out.println(ranString); - // 杩涜鍔犲瘑 sun.misc.BASE64Encoder.BASE64Encoder() - String enCode = new BASE64Encoder().encodeBuffer(ranString.getBytes()); - + String enCode = new String(Base64.getEncoder().encode(ranString.getBytes())); return enCode; } @@ -73,7 +63,8 @@ */ public static String simpleDeCode(String dataString) throws Exception { // 杩涜瑙e瘑sun.misc.BASE64Decoder.BASE64Decoder() - byte[] enCode = new BASE64Decoder().decodeBuffer(dataString); + + byte[] enCode = Base64.getDecoder().decode(dataString); // 瑙e緱闅忔満鍊� String ranString = new String(enCode); -- Gitblit v1.8.0