首页 > 其他 > 详细

图形验证码的使用

时间:2021-03-01 11:44:02      阅读:20      评论:0      收藏:0      [点我收藏+]

登录之图形验证码

1.后台控制禁止页面缓存

response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
response.setHeader("Pragma", "no-cache");
response.setContentType(MediaType.IMAGE_JPEG_VALUE);

开发设置中禁用缓存的参考博客:

转载自CSDN:https://blog.csdn.net/u014482758/article/details/43486081/

2.图片的base64编码

/**
 * 将图片二维码base64编码
 *
 * @param os 输出流
 * @return base64字符串
 * @throws IOException
 */
public static String encodeBase64ImgCode(ByteArrayOutputStream os)
    throws IOException {
  Objects.requireNonNull(os);
  byte[] b = os.toByteArray();
  String imgString = Base64.getEncoder().encodeToString(b);
  return BASE64_IMAGE_PREFIX + imgString;
}

图片base64编码的好处:(可阅读下面不错的一个博文)

转载自博客园:https://www.cnblogs.com/coco1s/p/4375774.html

图形验证码的使用

原文:https://www.cnblogs.com/erlangha/p/14462492.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!