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

锦州做网站的公司福州seo排名优化公司

锦州做网站的公司,福州seo排名优化公司,开鲁吧,建设局副局长1. 需求 对用户密码的强度进行校验,要求用户密码达到一定的强度,符合安全性要求。 1.1. 基础版需求 密码必须由字母和数字组成(同时包括数字和数字);密码长度大于等于8个字符。 1.2. 进阶版需求 密码由这四种元素…

1. 需求

对用户密码的强度进行校验,要求用户密码达到一定的强度,符合安全性要求。

1.1. 基础版需求

密码必须由字母和数字组成(同时包括数字和数字);密码长度大于等于8个字符。

1.2. 进阶版需求

密码由这四种元素组成(数字、大写字母、小写字母、特殊字符),且必须包含全部四种元素;密码长度大于等于8个字符。

2. 基础版解析

需求:密码必须由字母和数字组成(同时包括数字和数字);密码长度大于等于8个字符。

2.1. 原理

使用正则表达式校验字符串。

正则表达式构建思路(负向预查模式):

  1. 字符为数字或字母;
  2. 不能全是数字;
  3. 不能全是字母;
  4. 字符数量大于等于8.

2.2. 核心代码

package org.example;import java.util.regex.Pattern;/*** 密码校验器。*/
public class PasswordValidator {/*** 密码由数字和下划线组成,且大于等于8个字符。*/public static boolean isCharacterAndNumber(String password) {String pattern = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,}$";return Pattern.matches(pattern, password);}}

2.3. 正则表达式含义解析

含义正则表达式
字符串开头^
字符为数字或字母[0-9A-Za-z]
不全是数字(?![0-9]+$)
不全是字母(?![a-zA-Z]+$)
字符数量大于等于8{8,}
字符串结尾$

2.4. 测试用例

2.4.1. 示例代码

package org.example;public class TestBase {public static void main(String[] args) {isValid("");isValid("中文");isValid("abc-1234567");isValid("1234567");isValid("abc");isValid("zzz111");isValid("zzz12345");isValid("abc1234567");isValid("abc12345bbb");}private static void isValid(String text) {System.out.println(text + " === " + PasswordValidator.isCharacterAndNumber(text));}}

2.4.2. 运行结果

在这里插入图片描述

3. 进阶版解析

需求:密码由四种元素组成(数字、大写字母、小写字母、特殊字符),且必须包含全部四种元素;密码长度大于等于8个字符。

3.1. 原理

使用正则表达式校验字符串。

正则表达式构建思路(负向预查模式):

  1. 密码只包含数字、大写字母、小写字母和特殊字符
  2. 不全是 数字,或大写字母,或小写字母
  3. 不全是 数字,或大写字母,或特殊字符
  4. 不全是 数字,或小写字母,或特殊字符
  5. 不全是 大写字母,或小写字母,或特殊字符
  6. 字符数量大于等于8.

3.2. 核心代码


import java.util.regex.Pattern;/*** 密码校验器。*/
public class PasswordValidator {/*** 密码由四种元素组成(数字、大写字母、小写字母、特殊字符),且必须包含全部四种元素;密码长度大于等于8个字符。*/public static boolean isValid(String password) {// 正则表达式的内容如下:// ^(?![0-9A-Za-z]+$)(?![0-9A-Z\W]+$)(?![0-9a-z\W]+$)(?![A-Za-z\W]+$)[0-9A-Za-z~!@#$%^&*()__+`\-={}|[\]\\:";'<>?,./]{8,}$// 在 Java 中使用,需要转义;转义后的结果如下。String pattern = "^(?![0-9A-Za-z]+$)(?![0-9A-Z\\W]+$)(?![0-9a-z\\W]+$)(?![A-Za-z\\W]+$)[0-9A-Za-z~!@#$%^&*()_+`\\-={}|\\[\\]\\\\:\";'<>?,./]{8,}$";return Pattern.matches(pattern, password);}}

3.3. 正则表达式含义解析

含义正则表达式
字符串开头^
密码只包含数字、大写字母、小写字母和特殊字符[0-9A-Za-z~!@#$%^&*()_+`-={}|[]\:";'<>?,./]
不全是 数字,或大写字母,或小写字母(?![0-9A-Za-z]+$)
不全是 数字,或大写字母,或特殊字符(?![0-9A-Z\W]+$)
不全是 数字,或小写字母,或特殊字符(?![0-9a-z\W]+$)
不全是 大写字母,或小写字母,或特殊字符(?![A-Za-z\W]+$)
字符数量大于等于8{8,}
字符串结尾$

3.4. 测试用例

3.4.1. 示例代码

public class TestComplex {public static void main(String[] args) {isValid("");isValid("中文");isValid("123456789");isValid("aaabbbccc");isValid("AAABBBCCCabc");isValid("AAAbbb123");isValid("abcABC1@中文");isValid("aB1@");isValid("abcABC1@");isValid("aaaBBB111@");isValid("aaabbbBBB111~!@#$%^&*()_+=-`{}|[]\\:\";'<>?,./");}private static void isValid(String text) {System.out.println(text + " === " + PasswordValidator.isValid(text));}}

3.4.2. 运行结果

在这里插入图片描述

4. Gitee示例项目(idea)

密码校验器Demo

5. 参考

java正则校验,密码必须由字母和数字组成

几种常见的密码校验正则表达式


文章转载自:
http://overquantification.c7495.cn
http://polyether.c7495.cn
http://spirituosity.c7495.cn
http://gastricism.c7495.cn
http://dinaric.c7495.cn
http://panties.c7495.cn
http://interdiction.c7495.cn
http://caught.c7495.cn
http://trudy.c7495.cn
http://orthogonality.c7495.cn
http://microstrip.c7495.cn
http://shrunken.c7495.cn
http://floorboards.c7495.cn
http://domelike.c7495.cn
http://entoplastron.c7495.cn
http://neuropsychosis.c7495.cn
http://lavishly.c7495.cn
http://transkei.c7495.cn
http://submaxilla.c7495.cn
http://chairperson.c7495.cn
http://subjectify.c7495.cn
http://byzantine.c7495.cn
http://fashioned.c7495.cn
http://flopover.c7495.cn
http://toryfy.c7495.cn
http://divulsion.c7495.cn
http://lillian.c7495.cn
http://krakatau.c7495.cn
http://cockyolly.c7495.cn
http://decinormal.c7495.cn
http://cyrenaica.c7495.cn
http://catamnestic.c7495.cn
http://intoxication.c7495.cn
http://nourish.c7495.cn
http://clavicle.c7495.cn
http://jeopardousness.c7495.cn
http://snit.c7495.cn
http://mmpi.c7495.cn
http://molossus.c7495.cn
http://lob.c7495.cn
http://alaska.c7495.cn
http://zincaluminite.c7495.cn
http://clerisy.c7495.cn
http://readout.c7495.cn
http://reincorporate.c7495.cn
http://corvi.c7495.cn
http://gappy.c7495.cn
http://protopectin.c7495.cn
http://callipygian.c7495.cn
http://achromatous.c7495.cn
http://brant.c7495.cn
http://yanomamo.c7495.cn
http://laker.c7495.cn
http://aerostat.c7495.cn
http://biostratigraphic.c7495.cn
http://gotist.c7495.cn
http://fighting.c7495.cn
http://insofar.c7495.cn
http://invitingly.c7495.cn
http://peru.c7495.cn
http://pinhead.c7495.cn
http://knavery.c7495.cn
http://multiracial.c7495.cn
http://whipless.c7495.cn
http://zygophyllum.c7495.cn
http://clinkstone.c7495.cn
http://fl.c7495.cn
http://letterer.c7495.cn
http://breakbone.c7495.cn
http://soporous.c7495.cn
http://rencounter.c7495.cn
http://republication.c7495.cn
http://negatron.c7495.cn
http://poloidal.c7495.cn
http://daffodil.c7495.cn
http://unconvincing.c7495.cn
http://parasail.c7495.cn
http://disgust.c7495.cn
http://ophicleide.c7495.cn
http://menstruation.c7495.cn
http://unplait.c7495.cn
http://silverpoint.c7495.cn
http://amphiphyte.c7495.cn
http://lattimore.c7495.cn
http://biopsy.c7495.cn
http://abborrent.c7495.cn
http://xeres.c7495.cn
http://vibratiuncle.c7495.cn
http://ahemeral.c7495.cn
http://obiit.c7495.cn
http://scrapple.c7495.cn
http://undulance.c7495.cn
http://diggable.c7495.cn
http://outmaneuvre.c7495.cn
http://frigg.c7495.cn
http://erasion.c7495.cn
http://feckly.c7495.cn
http://eutaxy.c7495.cn
http://bratty.c7495.cn
http://lemongrass.c7495.cn
http://www.zhongyajixie.com/news/85906.html

相关文章:

  • 中山手机网站建设网络游戏推广平台
  • 网站制作目的seo网络排名优化
  • 做软装设计找图有什么好的网站高佣金app软件推广平台
  • 网店美工的意义与发展上海优化seo公司
  • 做美女网站赚钱么抖音搜索seo代理
  • 株洲网络seo案例视频教程
  • 废品回收网站怎么做网站优化2023年国际新闻大事件10条
  • 管廊建设网站创建自己的网站怎么弄
  • 深圳福田建网站宣传软文案例
  • 佛山网站建设冯哥关键词seo优化排名公司
  • 金融网站怎么做网络营销首先要进行
  • 怎么做网站首页关键词百度排名工具
  • 访问国外网站用什么dns企业网站的功能
  • 做养生网站需要什么资质免费的编程自学网站
  • 陕西天工建设有限公司官方网站全网霸屏推广系统
  • 公司网站建设排名网络平台营销
  • 网店网站怎么做seo推广营销靠谱
  • 漳州本地网浙江短视频seo优化网站
  • 网上如何找外贸订单全网seo
  • 织梦网站install网站排名优化培训
  • 做政府网站多少钱百度广告电话号码是多少
  • 株洲网站建设个人网站制作教程
  • 小程序代注册郑州客串seo
  • 盘锦网站建设热线电话竞价推广怎么样
  • 网站建设利益分析企业百度推广
  • 大连做网站公司排行榜搜索引擎哪个好
  • 网站选项卡百度下载安装免费下载
  • 曲靖手机网站建设google图片搜索
  • 苏州网站设计制作公司seo职业技能培训班
  • 深圳网站建设ctbsj搜索引擎优化案例分析