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

怎么做qq可信任网站裤子seo关键词

怎么做qq可信任网站,裤子seo关键词,网站开发技术项目式教程,网站建设佰首选金手指十生成随机密码 符合密码强度的密码要求: 至少有一个大写字母至少有一个小写字母至少有一个数字至少有一个特殊字符长度满足要求(通常为8-16位) // 大写字母private static final String UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ";…

生成随机密码

符合密码强度的密码要求:

  • 至少有一个大写字母
  • 至少有一个小写字母
  • 至少有一个数字
  • 至少有一个特殊字符
  • 长度满足要求(通常为8-16位)
    // 大写字母private static final String UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";// 小写字母private static final String LOWERCASE = "abcdefghijklmnopqrstuvwxyz";// 数字private static final String DIGITS = "0123456789";// 特殊字符(支持空格-下发密码明文时需要关注空格)private static final String SPECIAL_CHARS = "`~!@#$%^&*()-_=+[]{}\\|;:'\",.<>/? ";// 最小长度private static final int MIN_LENGTH = 8;// 最大长度private static final int MAX_LENGTH = 16;private static final SecureRandom random = new SecureRandom();/*** 生成随机密码* 满足强度要求* 长度随机** @return 生成的密码*/public static String generatePassword() {int length = MIN_LENGTH + random.nextInt(MAX_LENGTH - MIN_LENGTH);return generatePassword(length);}/*** 生成符合强密码要求的随机密码** @param length 密码长度* @return 生成的密码* @throws IllegalArgumentException 长度不满足要求*/public static String generatePassword(int length) {if (length < MIN_LENGTH || length > MAX_LENGTH) {throw new IllegalArgumentException("invalid password length.");}List<Character> passwordChars = new ArrayList<>();// 确保每类字符至少出现一次addRandomChar(passwordChars, UPPERCASE);addRandomChar(passwordChars, LOWERCASE);addRandomChar(passwordChars, DIGITS);addRandomChar(passwordChars, SPECIAL_CHARS);// 填充剩余字符String allChars = UPPERCASE + LOWERCASE + DIGITS + SPECIAL_CHARS;for (int i = 4; i < length; i++) {addRandomChar(passwordChars, allChars);}// 打乱字符顺序Collections.shuffle(passwordChars, random);// 构建密码字符串StringBuilder password = new StringBuilder();for (char c : passwordChars) {password.append(c);}return password.toString();}/*** 从指定字符串中随机选取一个字符并添加到密码列表中*/private static void addRandomChar(List<Character> list, String charSet) {int index = random.nextInt(charSet.length());list.add(charSet.charAt(index));}

校验密码强度有效性

    // "^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d)(?=.*[\\Q`~!@#$%^&*()-_=+[]{}\\|;:'\",.<>/? \\E]).{8,16}$"private static final Pattern PATTERN_VALID_PASSWORD = Pattern.compile("^" +"(?=.*[A-Z])" +"(?=.*[a-z])" +"(?=.*\\d)" +"(?=.*[" + Pattern.quote(SPECIAL_CHARS) + "])" +".{" + MIN_LENGTH + "," + MAX_LENGTH + "}"+ "$");/*** 判断密码强度是否满足要求* 长度为8-16位(可按照实际修改)* 必须包含大写字母,小写字母,数字,特殊字符** @param input 带验证的密码明文* @return 是否满足强度要求*/public static boolean isValid(String input) {if (input == null || input.isEmpty()) {return false;}return PATTERN_VALID_PASSWORD.matcher(input).matches();}

单元测试

package com.ysx.utils.security;import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;import java.util.stream.Stream;import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;/*** @author youngbear* @email youngbear@aliyun.com* @date 2025-05-06 18:41* @blog <a href="https://blog.csdn.net/next_second">...</a>* @github <a href="https://github.com/YoungBear">...</a>* @description test for {@link PasswordUtils}*/
class PasswordUtilsTest {private static final Logger LOGGER = LoggerFactory.getLogger(PasswordUtilsTest.class);@Testvoid generatePasswordTestForRandomLength() {String password = PasswordUtils.generatePassword();LOGGER.info("password: {}, length: {}.", password, password.length());assertTrue(password.length() >= 8);assertTrue(password.length() <= 16);}@Testvoid generatePasswordTestForSpecifiedLength() {int length = 10;String password = PasswordUtils.generatePassword(length);LOGGER.info("password: {}, length: {}.", password, password.length());assertEquals(length, password.length());}private static Stream<String> validPasswordProvider() {return Stream.of("Abc@2025","2025~xyZ","(2020#Abc"," Abc2025","~!@#$%Aa0","2020$123$abc$ABC","Aa0`2025@2026^Xy");}private static Stream<String> inValidPasswordProvider() {return Stream.of(null,"","2025~xZ","2025~xZ12ab34CD56","(2020#abc","(2020#ABC","2020Abcd");}@ParameterizedTest(name = "#{index} - Run test with isValid = {0}")@MethodSource("validPasswordProvider")void test_isValid_input_valid(String input) {assertTrue(PasswordUtils.isValid(input));}@ParameterizedTest(name = "#{index} - Run test with isValid = {0}")@MethodSource("inValidPasswordProvider")void test_isValid_input_inValid(String input) {assertFalse(PasswordUtils.isValid(input));}
}

源代码地址

  • github
  • gitee

文章转载自:

http://UOBH0gE5.psdbf.cn
http://OGOibSAZ.psdbf.cn
http://UpG4fXUb.psdbf.cn
http://vl2xU8pB.psdbf.cn
http://4sudYoQ0.psdbf.cn
http://mlm3aeKV.psdbf.cn
http://yVl4fn7G.psdbf.cn
http://yke8EhJa.psdbf.cn
http://5VXB32n9.psdbf.cn
http://Z6FFt3LR.psdbf.cn
http://zdlBFn05.psdbf.cn
http://Z74BRGyC.psdbf.cn
http://Wlj8C7aw.psdbf.cn
http://LcqLtHps.psdbf.cn
http://oUMXLA1c.psdbf.cn
http://xZgE1pQP.psdbf.cn
http://utkNZ5OL.psdbf.cn
http://ESLXlUi8.psdbf.cn
http://J7WO9QI2.psdbf.cn
http://FNYyPlWZ.psdbf.cn
http://2ibNLfFy.psdbf.cn
http://2EPd9hzh.psdbf.cn
http://0QucO0Lk.psdbf.cn
http://nvkZnAMV.psdbf.cn
http://44ZkLfJB.psdbf.cn
http://YyuVF8n0.psdbf.cn
http://3ICeq8EI.psdbf.cn
http://vGzn7UZ5.psdbf.cn
http://g5gv0nza.psdbf.cn
http://63iHHfdi.psdbf.cn
http://www.dtcms.com/wzjs/662230.html

相关文章:

  • 东莞做网站价格收费小说网站怎么做
  • 内网网站开发报价自建网站怎么做二级页跳转
  • 烘焙食品网站建设需求分析怎么搭建本地网站
  • 常用wap网站开发工具 手机网站制台州市网站建设
  • 网站英语西安高新区网站建设
  • 网站建设步骤完整版广东网页空间网站
  • wordpress modern adminseo竞价
  • 网页设计与网站建设书一个页面的html5网站模板 psd
  • 网站开发用原生自己的网站如何让百度收录
  • seo门户网站建设方案西安网站建设资讯
  • 在阿里巴巴上做网站需要什么建立一个网页需要多少钱
  • 新乡网站建设多少钱网站内备案名称 修改
  • 西安网站建设第一品牌wordpress怎么调度主题
  • 网站建设与维护笔记软件设计公司
  • 网站做多少分辨率哈尔滨建设公司网站
  • 巴中市建设局网站小区网站建设方案怎么写
  • 上饶哪有做网站的公司域名注册信息
  • 海口有做棋牌娱乐网站的吗鼓楼做网站公司哪家好
  • 猎奇网站模板兼职网站制作
  • 广西住房和城乡建设厅网站证件免费制作论坛网站模板
  • 网站建设费用价格明细表鞋材 技术支持 东莞网站建设
  • 如何建立p2p网站android手机开发工具
  • 做公司网站500元域名到期怎么续费
  • 10m带宽做下载网站什么网站做ppt模板
  • 广州网站seo招聘网上商城取名
  • 网站建设都一般步骤网站开发质量管理
  • 数学网站怎么做做网站买一个域名多少钱
  • 普通的宣传网站用什么做临沂市建设局兰山区网站
  • 建站程序免费下载赣州有没有做网站的
  • 北京小程序开发推荐青岛信息优化排名推广