diff --git a/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/ImageUtils.java b/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/ImageUtils.java index aa3837f..32c65d6 100644 --- a/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/ImageUtils.java +++ b/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/ImageUtils.java @@ -1,9 +1,8 @@ package com.yxt.common.base.config.captcha; - +import cn.hutool.core.codec.Base64; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import sun.misc.BASE64Decoder; import java.io.*; @@ -89,12 +88,12 @@ public class ImageUtils { return false; } - BASE64Decoder decoder = new BASE64Decoder(); +// BASE64Decoder decoder = new BASE64Decoder(); OutputStream out = null; try { out = new FileOutputStream(imgFilePath); // Base64解码 - byte[] b = decoder.decodeBuffer(imgData); + byte[] b = Base64.decode(imgData); for (int i = 0; i < b.length; ++i) { // 调整异常数据 if (b[i] < 0) { diff --git a/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/factory/impl/AbstractCaptcha.java b/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/factory/impl/AbstractCaptcha.java index f65b502..79bc25f 100644 --- a/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/factory/impl/AbstractCaptcha.java +++ b/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/factory/impl/AbstractCaptcha.java @@ -1,10 +1,10 @@ package com.yxt.common.base.config.captcha.factory.impl; +import cn.hutool.core.codec.Base64; import com.yxt.common.base.config.captcha.CaptchaBaseParam; import com.yxt.common.base.config.captcha.CaptchaException; import com.yxt.common.core.vo.CaptchaBaseVO; import org.apache.commons.lang3.StringUtils; -import sun.misc.BASE64Encoder; import javax.imageio.ImageIO; import java.awt.*; @@ -75,8 +75,7 @@ public abstract class AbstractCaptcha { throw new CaptchaException("ImageIO.write is error", e); } byte[] bytes = baos.toByteArray(); - BASE64Encoder encoder = new sun.misc.BASE64Encoder(); - return encoder.encodeBuffer(bytes).trim(); + return Base64.encode(bytes).trim(); } public String getJigsawUrlOrPath() { diff --git a/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/factory/impl/BlockPuzzleCaptcha.java b/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/factory/impl/BlockPuzzleCaptcha.java index 615b556..e7fea2e 100644 --- a/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/factory/impl/BlockPuzzleCaptcha.java +++ b/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/captcha/factory/impl/BlockPuzzleCaptcha.java @@ -1,12 +1,12 @@ package com.yxt.common.base.config.captcha.factory.impl; +import cn.hutool.core.codec.Base64; import com.alibaba.fastjson.JSON; import com.yxt.common.base.config.captcha.CaptchaBaseParam; import com.yxt.common.base.config.captcha.CaptchaException; import com.yxt.common.core.vo.BlockPuzzleCaptchaVO; import com.yxt.common.core.vo.CaptchaBaseVO; import org.apache.commons.lang3.StringUtils; -import sun.misc.BASE64Encoder; import javax.imageio.ImageIO; import java.awt.*; @@ -87,10 +87,9 @@ public class BlockPuzzleCaptcha extends AbstractCaptcha { // 源图生成遮罩 byte[] oriCopyImages = DealOriPictureByTemplate(originalImage, jigsawImage, x, 0); - BASE64Encoder encoder = new sun.misc.BASE64Encoder(); - dataVO.setOriginalImageBase64(encoder.encode(oriCopyImages)); + dataVO.setOriginalImageBase64(Base64.encode(oriCopyImages)); dataVO.setPoint(point); - dataVO.setJigsawImageBase64(encoder.encode(jigsawImages)); + dataVO.setJigsawImageBase64(Base64.encode(jigsawImages)); return dataVO; } catch (Exception e){ throw new CaptchaException(e); diff --git a/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/component/DocPdfComponent.java b/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/component/DocPdfComponent.java index 3d04d0e..1ae2d8f 100644 --- a/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/component/DocPdfComponent.java +++ b/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/config/component/DocPdfComponent.java @@ -1,5 +1,6 @@ package com.yxt.common.base.config.component; +import cn.hutool.core.codec.Base64; import cn.hutool.core.date.DateUtil; import com.jacob.activeX.ActiveXComponent; import com.jacob.com.Dispatch; @@ -11,7 +12,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import sun.misc.BASE64Encoder; import java.io.*; import java.util.Date; @@ -94,8 +94,7 @@ public class DocPdfComponent { } catch (Exception e) { e.printStackTrace(); } - BASE64Encoder encoder = new BASE64Encoder(); - return encoder.encode(data); + return Base64.encode(data); } /** diff --git a/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/utils/WordUtils.java b/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/utils/WordUtils.java index 59d5f69..15a7bae 100644 --- a/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/utils/WordUtils.java +++ b/yxt-common/yxt-common-base/src/main/java/com/yxt/common/base/utils/WordUtils.java @@ -1,12 +1,12 @@ package com.yxt.common.base.utils; +import cn.hutool.core.codec.Base64; import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComThread; import com.jacob.com.Dispatch; import freemarker.template.Configuration; import freemarker.template.Template; import freemarker.template.Version; -import sun.misc.BASE64Encoder; import java.io.*; import java.util.*; @@ -73,8 +73,7 @@ public class WordUtils { } catch (Exception e) { e.printStackTrace(); } - BASE64Encoder encoder = new BASE64Encoder(); - return encoder.encode(data); + return Base64.encode(data); } /**