当前位置: 首页 > news >正文

聊城seo整站优化报价开一个网站建设公司好

聊城seo整站优化报价,开一个网站建设公司好,江苏建设机械网站,毕业设计做网站 如何做通过时间获取验证码 1.需求2.代码实现2.1 依赖2.2 时间参数处理方法2.3 截取验证码方法2.4 验证方法 3.总结 1.需求 要求是很简单的#xff0c;每个验证码的有效时间是2小时#xff0c;这个并不是收到验证码开始计时的#xff0c;而是每个两小时的时间段使用的是相同的验证… 通过时间获取验证码 1.需求2.代码实现2.1 依赖2.2 时间参数处理方法2.3 截取验证码方法2.4 验证方法 3.总结 1.需求 要求是很简单的每个验证码的有效时间是2小时这个并不是收到验证码开始计时的而是每个两小时的时间段使用的是相同的验证码。 2.代码实现 2.1 依赖 dependencygroupIdgov.nist.math/groupIdartifactIdjama/artifactIdversion1.0.3/version /dependencydependencygroupIdcommons-codec/groupIdartifactIdcommons-codec/artifactIdversion1.6/version /dependency2.2 时间参数处理方法 将2个小时处理为相同的值 Slf4j public class VerificationCodeUtil {/*** 时间字符串** param dateStr yyyy-MM-dd HH:mm:ss*/public static String getCode(String dateStr) {int dataStrLength 13;try {if (dateStr.length() dataStrLength) {String yearMonthDay dateStr.substring(0, 10);int hour Integer.parseInt(dateStr.substring(11, 13));int twoHour 2;if (hour % twoHour ! 0) {hour--;}String md5Str DigestUtils.md5Hex(vc# yearMonthDay hour);return getCodeByMd5(md5Str);} else {log.error(dateStr [{}] not match format [yyyy-MM-dd HH:mm:ss]!, dateStr);}} catch (Exception e) {e.printStackTrace();log.error(dateStr [{}] not match format [yyyy-MM-dd HH:mm:ss]!, dateStr);}return dateStr;} }2.3 截取验证码方法 Slf4j public class VerificationCodeUtil {// 对指定字符串生成验证码private static String getCodeByMd5(String md5Str) {try {byte[] md5 md5Str.getBytes();double[][] preMatrix new double[4][8];for (int j 0; j 4; j) {for (int k 0; k 8; k) {preMatrix[j][k] md5[j * 8 k];}}Matrix matrix new Matrix(preMatrix);Matrix matrix1 matrix.getMatrix(1, 2, 2, 5);Matrix matrix2 matrix.transpose();Matrix matrix21 matrix2.getMatrix(0, 3, 0, 3);Matrix matrix22 matrix2.getMatrix(4, 7, 0, 3);Matrix matrix3 matrix21.plus(matrix22);Matrix result matrix1.times(matrix3);double[][] re result.getArray();StringBuilder str new StringBuilder();for (double[] doubles : re) {for (double aDouble : doubles) {int a (int) aDouble % 16;str.append(Integer.toHexString(a));}}return str.toString().toUpperCase();} catch (Exception e) {e.printStackTrace();return null;}} }2.4 验证方法 Slf4j public class VerificationCodeUtil {public static void main(String[] args) {DateFormat df new SimpleDateFormat(yyyy-MM-dd HH:mm:ss);DateTime parse DateUtil.parse(2023-11-09 23:59:59, yyyy-MM-dd HH:mm:ss);String format df.format(parse);System.out.println(getCode(format));// 00:00 3A756DFC// 00:59 3A756DFC// 01:59 3A756DFC// 01:59 3A756DFC// 02:00 9E937D4B// 02:59 9E937D4B// 03:00 9E937D4B// 22:00 D014DD79// 23:59 D014DD79 } }3.总结 很简单的算法分享。优点 不需要将生成的验证码缓存。时间入参能够重复获取相同的值。
http://www.yayakq.cn/news/2730/

相关文章:

  • 门户网站建设方案 ppthtml5 手机网站 教程
  • 网站建设技术外文文献丹阳网站建设开发
  • 站酷设计师网站百度大数据分析工具
  • 做拍拍拍拍网站谁有人和兽做的网站?
  • 手机 网站 开发网站负责人核验照
  • 滨海做网站的网站建设目的分析
  • mysql 网站空间玉树营销网站建设哪家好
  • 绚丽网站模板wordpress安装主题后打不开
  • 网站建设怎么样工作关于网站建设的合同范本
  • 综合门户网站是什么意思装修公司加盟免费
  • 建设网站好公司哪家好WordPress版本识别
  • 网站建设中 下载西安建设工程有限公司
  • 自适应影视网站模板网站浮动qq
  • 网站开发html工具江苏省公路与水路建设网站
  • 聊城网站制作价格网站栏目结构
  • 公司网站一年费用合肥商城网站建设
  • 佛山网站建设锐艺a068技术支持 张家港网站建设
  • 长沙手机网站首页设计公司网页设计主要用什么软件
  • 百度链接提交百度seo优化排名软件
  • 商城网站建设大连在线制作离婚证图片
  • 网站建设核心优势培训中心网站建设
  • 企业网站推广优化广州建站哪个济南兴田德润实惠吗
  • 创新型的福州网站建设网站平台建设缴纳什么税
  • 国家建设官方网站aws使用wordpress
  • 建网站不做广告怎么赚钱如何做网站站长
  • 经开区网站建设扫wordpress后台
  • 淘宝建站程序网站开发项目的简介
  • 哈尔滨网站制作建设多少钱仿抖音网站开发
  • 福州网站平台建设公司电子商务平台建设实施方案
  • 那种做任务的网站叫什么wordpress 直播网站