fix: 修复symbol: [ERROR]->class BASE64Encoder/[ERROR]->location: package sun.misc
This commit is contained in:
@@ -1,28 +1,21 @@
|
||||
package com.schisandra.auth.application.controller;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
|
||||
import com.schisandra.auth.application.dto.SchisandraCaptchaDTO;
|
||||
import com.schisandra.auth.common.entity.CaptchaResult;
|
||||
import com.schisandra.auth.common.entity.Result;
|
||||
import com.schisandra.auth.common.redis.RedisUtil;
|
||||
import com.schisandra.auth.common.utils.AESUtils;
|
||||
import com.schisandra.auth.common.utils.RotateImageUtils;
|
||||
import com.schisandra.auth.common.utils.SmsCodeUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Base64;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@@ -1,18 +1,16 @@
|
||||
package com.schisandra.auth.common.utils;
|
||||
|
||||
import sun.misc.BASE64Decoder;
|
||||
import sun.misc.BASE64Encoder;
|
||||
import java.util.Base64;
|
||||
import java.util.Base64.Encoder;
|
||||
import java.util.Base64.Decoder;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class RotateImageUtils {
|
||||
|
||||
@@ -45,8 +43,8 @@ public class RotateImageUtils {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();//io流
|
||||
ImageIO.write(outputImage, "png", baos);//写入流中
|
||||
byte[] bytes = baos.toByteArray();//转换成字节
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
String png_base64 = encoder.encodeBuffer(bytes).trim();//转换成base64串
|
||||
Encoder encoder = Base64.getEncoder();
|
||||
String png_base64 = encoder.encodeToString(bytes);//转换成base64串
|
||||
png_base64 = png_base64.replaceAll("\n", "").replaceAll("\r", "");//删除 \r\n
|
||||
return "data:image/jpg;base64," + png_base64;
|
||||
|
||||
@@ -60,9 +58,9 @@ public class RotateImageUtils {
|
||||
* @date: 2024/5/9 13:14
|
||||
*/
|
||||
public static BufferedImage base64ToBufferedImage(String base64) {
|
||||
BASE64Decoder decoder = new sun.misc.BASE64Decoder();
|
||||
Decoder decoder = Base64.getDecoder();
|
||||
try {
|
||||
byte[] bytes1 = decoder.decodeBuffer(base64);
|
||||
byte[] bytes1 = decoder.decode(base64);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(bytes1);
|
||||
return ImageIO.read(bais);
|
||||
} catch (IOException e) {
|
||||
|
Reference in New Issue
Block a user