Commit e9182f2c authored by linlinjava's avatar linlinjava
Browse files

#468

parent ba439aa7
...@@ -25,7 +25,6 @@ import org.springframework.context.ApplicationContext; ...@@ -25,7 +25,6 @@ import org.springframework.context.ApplicationContext;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import sun.misc.BASE64Encoder;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -75,10 +74,8 @@ public class AdminAuthController { ...@@ -75,10 +74,8 @@ public class AdminAuthController {
try { try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ImageIO.write(image, "jpeg", outputStream); ImageIO.write(image, "jpeg", outputStream);
BASE64Encoder encoder = new BASE64Encoder(); String base64 = Base64.getEncoder().encodeToString(outputStream.toByteArray());
String base64 = encoder.encode(outputStream.toByteArray()); return "data:image/jpeg;base64," + base64.replaceAll("\r\n", "");
String captchaBase64 = "data:image/jpeg;base64," + base64.replaceAll("\r\n", "");
return captchaBase64;
} catch (IOException e) { } catch (IOException e) {
return null; return null;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment