@angular-material-extensions/password-strength

中文文档
16.0.0发布于 2023/11/05MITTypeScriptES Module近 30 天下载 3.1万

显示密码的安全性的材料密码强度表

中文使用文档
文档目录28 节
  1. 由开发者建并供开发者使用 : 心脏 :
  2. 目录
  3. 演示
  4. 图书馆的组成部分
  5. 依赖关系
  6. 安装
  7. 1. 通过 纳克后加 . (建议)
  8. 2. 通过 无 . (备选案文)
  9. 导入库
  10. API 密码
  11. <mat-password-strength> 用于计算和显示提供密码的强度 - 参见演示示例
  12. <mat-password-strength-info> 用于显示更多关于提供密码强度的信息 - 参见演示示例
  13. <mat-pass-toggle-visibility> 用于显示/隐藏输入元素中提供的密码
  14. 使用量
  15. 在以下例子中,我们将一个材料输入容器与 @angular-material-extensions/password-s…
  16. 如何在模板中使用密码所释放的强度的实例
  17. 使用切换能见度组件
  18. 客户端密码使用 angular 格式控制器验证
  19. 自定义正则x 验证
  20. 确认密码以角窗体控制器构建 - 参见现场实例
  21. 总是使用绿色来获取一个强大的密码,只需添加 green cs 类到 mat-password-strength
  22. 支持信息组件的自定义信件和ngx- translate 请检查示例演示 这里
  23. 本地运行 Demo 应用程序
  24. 发展
  25. 其他角图书馆
  26. 支助
  27. 谁用这个图书馆? 伟大的应用程序?
  28. 许可证

angular-material-extensions's logo

@angular-material-expensions/password-strength - 材料密码强度计,以显示所提供的密码是否安全

npm version npm demo docs: typedoc Join the chat at https://gitter.im/angular-material-extensions/Lobby CircleCI branch Build Status codecov dependency Status devDependency Status Greenkeeper Badge license Awesome

@angular-material-extensions/password-strength demonstration

由开发者建并供开发者使用 : 心脏 :

你有什么问题或建议吗? 请不要犹豫联系我们! 或者,提供PR QQ打开一个适当的问题 这里

如果你喜欢这个项目,请支持 角-材料-扩展 由主演: 明星: 分享它 : 高音:

目录

演示

在 https://angular-material-extension.github.io/password-strength 页面存档备份,存于互联网档案馆

图书馆的组成部分

  • <mat-password-strength> 用于计算和显示提供密码的强度
  1. 强度得分 20%

@angular-material-extensions/password-strength score less than 20%

  1. 强度得分 80%

@angular-material-extensions/password-strength score less than 40%

  1. 强度分数 > 80%

@angular-material-extensions/password-strength score less than 100%

  • <mat-password-strength-info> 用于显示更多关于提供密码强度的信息

@angular-material-extensions/password-strength's info

  • <mat-pass-toggle-visibility> 用于显示/隐藏输入元素中提供的密码

@angular-material-extensions/password-strength's info


依赖关系


安装

如果未设置角材料设计, 请运行 ng add @angular/material 学习更多

现在通过 angular schematics

ng add @angular-material-extensions/password-strength

2. 通过 无. (备选案文)

现在安装 @angular-material-extensions/password-strength 通过:

npm install --save @angular-material-extensions/password-strength

系统JS

说明: 如果您正在使用 SystemJS,您应该调整您的配置,以指向 UMD 捆绑. 在您的系统配置文件中, map 需要告诉系统加载器在哪里寻找 @angular-material-extensions/password-strength数字 :

{
  '@angular-material-extensions/password-strength';: 'node_modules/@angular-material-extensions/password-strength/bundles/password-strength.umd.js',
}

-> follow the instructions 这里


导入库

安装后需要导入主模块 :

import { MatPasswordStrengthModule } from "@angular-material-extensions/password-strength";

剩下的唯一部分是在您的应用程序模块中列出导入的模块. 准确的方法是略微的 不同的根( 顶级) 模块, 您最后应该使用类似于( 通知) 的代码 MatPasswordStrengthModule .forRoot():

import { MatPasswordStrengthModule } from '@angular-material-extensions/password-strength';

@NgModule({
  declarations: [AppComponent, ...],
  imports: [MatPasswordStrengthModule.forRoot(), ...],
  bootstrap: [AppComponent]
})
export class AppModule {
}

应用程序中的其他模块可以简单地导入 MatPasswordStrengthModule数字 :

import { MatPasswordStrengthModule } from '@angular-material-extensions/password-strength';

@NgModule({
  declarations: [OtherComponent, ...],
  imports: [MatPasswordStrengthModule, ...],
})
export class OtherModule {
}

API 密码

<mat-password-strength> 用于计算和显示提供密码的强度 - 参见演示示例

选项绑定类型默认说明
密码Input() 字符串- 说吧用于计算其强度的密码
自定义变量Input() 正则Exp- 说吧自定义 regex 验证符
外部错误Input() booleanfalse用于更改密码的颜色以警告外部出错
启用 Length 规则Input() booleantrue是否验证密码长度
启用下目录规则Input() booleantrue小写字母是否可选
启用 UpperCaseletter 规则Input() booleantrue大写字母是否可选
启用数字规则Input() booleantrue数字字符是否可选
启用特别查尔规则Input() boolean真实特殊字符是否可选
分钟Input() number第8条密码的最小长度
最大数Input() number30个密码的最大长度
警告危险Input() number21国密码强度小于此数字显示警告颜色
重音威胁Input() number81国道密码强度小于此数字显示口音颜色
已改变产出( )number- 说吧提供密码的强度以%表示,例如:20%、40%、60%、80%或100%

<mat-password-strength-info> 用于显示更多关于提供密码强度的信息 - 参见演示示例

选项绑定类型默认说明
密码组件Input() 密码Strength 组件- 说吧模板中用于显示更多与所提供的密码有关的信息的密码组件
启用分数信息Input() booleanfalse是否以 % 显示密码的分数
下目录Input() string包含至少一个下字符小案件的适当毫升 %
上目录Input() string至少包含一个上字符较大病例的适当毫升 %
数字Input() string包含至少一个数字字符数字大小写的适当 msg %
特殊目录Input() string包含至少一个特殊字符特殊情况的适当 msg %
自定义 Chars 标准磁斯Input() string至少包含一个自定义字符用于自定义验证器大小写的适当 msg %
微分目录Input() string包含至少 ${ this. password Conferent.min} 字符最低限度的适当 msg number 字符数%

<mat-pass-toggle-visibility> 用于显示/隐藏输入元素中提供的密码

选项绑定类型默认说明
可视Input() booleanfalse密码是否可见或隐藏
选项卡Input() stringnull设置切换可见度按钮的所期望的标签索引值.

使用量

添加 @angular-material-extensions/password-strength 模板中的元素 :

<mat-password-strength [password]="password.value"> </mat-password-strength>

这将仅以没有任何输入字段的进度形式显示 或类似.

在以下例子中,我们将一个材料输入容器与 @angular-material-extensions/password-strength 组件.

注:为了在改变密码强度值后正确重新油漆垫面-窗体-场,请考虑 更改母组件的检测策略 -- >

import {
  ChangeDetectionStrategy,
  Component,
  OnInit,
  ViewEncapsulation,
} from "@angular/core";
import { Title } from "@angular/platform-browser";
import { MatSlideToggleChange } from "@angular/material";
import { MatPasswordStrengthComponent } from "@angular-material-extensions/password-strength";

@Component({
  selector: "app-home",
  templateUrl: "./home.component.html",
  styleUrls: ["./home.component.scss"],
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HomeComponent implements OnInit {}
<div>
  <mat-form-field
    appearance="outline"
    style="width: 100%"
    [color]="passwordComponent.color"
  >
    <mat-label>Password</mat-label>
    <input
      matInput
      #password
      [type]="inputType"
      required
      placeholder="Password"
    />
    <mat-hint align="end" aria-live="polite">
      {{password.value.length}} / 25
    </mat-hint>
  </mat-form-field>

  <mat-password-strength
    #passwordComponent
    (onStrengthChanged)="onStrengthChanged($event)"
    [password]="password.value"
  >
  </mat-password-strength>
</div>

学习更多关于平面-外野

如何在模板中使用密码所释放的强度的实例

<div fxLayout="row" fxLayoutGap="10px">
  <div *ngIf="passwordComponent.strength === 100; then done else error"></div>
  <ng-template #done>
    <mat-icon color="primary">done</mat-icon>
  </ng-template>
  <ng-template #error>
    <mat-icon color="warn">error</mat-icon>
  </ng-template>
  <div>
    <p>Password's strength = {{passwordComponent.strength}} %100</p>
  </div>
</div>

使用切换能见度组件

  • 添加 mat-pass-toggle-visibility 给您的 mat-form-field
  • 给它一个名字,在 html 文件中使用它像 toggle
  • 设置从 mat-pass-toggle-visibility 组件 <input matInput [type]="toggle.type"/>
<mat-form-field
  appearance="outline"
  style="width: 100%"
  [color]="passwordComponent.color"
>
  <mat-label>Password</mat-label>
  <!-- HERE DOWN :D-->
  <mat-pass-toggle-visibility #toggle matSuffix></mat-pass-toggle-visibility>
  <!-- THERE ABOVE ;)-->
  <input
    matInput
    #password
    [type]="toggle.type"
    required
    placeholder="Password"
  />
  <mat-hint align="end" aria-live="polite">
    {{password.value.length}} / 25
  </mat-hint>
</mat-form-field>

客户端密码使用 angular 格式控制器验证

  1. 在您的模板中添加一个输入元素, 并配有适当的 @ angular- material- extensions/ password-strength 组件
  2. 通过添加来保留@angular-material-extension/password-strength 组件的引用 passwordComponentWithValidation (或任何你想要的)元素内部

例如:

<mat-password-strength
  #passwordComponentWithValidation
  [password]="passwordWithValidation.value"
>
</mat-password-strength>
  1. 将 sat-password-strength 的窗体控制器绑入输入元素
  • 您可以使用 khile 视图访问 @angular- material- extension/ password- strength 的窗体控制器 -- > passwordComponentWithValidation.passwordFormControl
  • 将窗体控制器绑定为输入元素 -- > [formControl]="passwordComponentWithValidation.passwordFormControl"
  1. 完整的例子----见下文
<div>
  <mat-form-field appearance="outline" style="width: 100%">
    <mat-label>Password</mat-label>
    <input
      matInput
      #passwordWithValidation
      [type]="inputType"
      required
      [formControl]="passwordComponentWithValidation.passwordFormControl"
      placeholder="Password"
    />
    <mat-hint align="end" aria-live="polite">
      {{passwordWithValidation.value.length}} / 25
    </mat-hint>
    <mat-error
      *ngIf="passwordComponentWithValidation.passwordFormControl.hasError('required')"
    >
      Password is required
    </mat-error>
    <mat-error
      *ngIf="passwordComponentWithValidation.passwordFormControl.hasError('pattern')"
    >
      Password is not valid
    </mat-error>
  </mat-form-field>
  <mat-password-strength
    #passwordComponentWithValidation
    (onStrengthChanged)="onStrengthChanged($event)"
    [password]="passwordWithValidation.value"
  >
  </mat-password-strength>
  <!--Password's strength info-->
  <mat-password-strength-info
    [passwordComponent]="passwordComponentWithValidation"
  >
  </mat-password-strength-info>
</div>

这将看起来像 -- >

@angular-material-extensions/password-strength


自定义正则x 验证

请考虑使用 customValidator 投入(见下文)

<mat-slide-toggle #toggle>Show Password Details</mat-slide-toggle>

<mat-form-field
  appearance="outline"
  style="width: 100%"
  [color]="passwordComponent.color"
>
  <mat-label>Password</mat-label>
  <mat-pass-toggle-visibility
    #toggleVisbility
    matSuffix
  ></mat-pass-toggle-visibility>
  <input
    matInput
    #password
    [type]="toggleVisbility.type"
    placeholder="Password"
  />
  <mat-hint align="end" aria-live="polite">
    {{password.value.length}} / {{passwordComponent.max}}
  </mat-hint>
</mat-form-field>

<mat-password-strength
  #passwordComponent
  (onStrengthChanged)="onStrengthChanged($event)"
  [password]="password.value"
  [customValidator]="pattern"
>
</mat-password-strength>

<mat-password-strength-info
  *ngIf="toggle.checked"
  [passwordComponent]="passwordComponent6"
  customCharsCriteriaMsg="1 german special chars is required"
  [enableScoreInfo]="true"
>
</mat-password-strength-info>
pattern = new RegExp(/^(?=.*?[äöüÄÖÜß])/);

确认密码以角窗体控制器构建 - 参见现场实例

@angular-material-extensions/password-strength with confirmation feature

@angular-material-extensions/password-strength with confirmation feature

总是使用绿色来获取一个强大的密码,只需添加 green cs 类到 mat-password-strength

<mat-password-strength
  #passwordComponent
  class="green"
  [password]="password.value"
>
</mat-password-strength>

支持信息组件的自定义信件和ngx- translate 请检查示例演示 这里

@angular-material-extensions/password-strength demonstration

更多实例请访问此 URL : [(]https://angular-material-extension.github.io/password-strength/examples 页面存档备份,存于互联网档案馆(] ([https://angular-material-extension.github.io/password-strength/examples 页面存档备份,存于互联网档案馆(中文(简体) )

请检查完整的文档 这里 或跟随官员 教程


本地运行 Demo 应用程序

发展

其他角图书馆


支助

由开发商建造


谁用这个图书馆? 伟大的应用程序?

  1. Nahaus.de - Digitale und automatisierte Immobileenverwaltung 软件软件公司 Vermietter und Hausverwaltungen

你错过了你的项目还是你的应用? 公关我发表在读本上



jetbrains logo

这个项目得到下列机构的支持: 喷射板 1个产品包 OS License 包括. 网络风暴


许可证

版权(c) 2019-2023 安东尼·纳哈斯获得麻省理工学院许可证

版本与发布记录

@angular-material-extensions/password-strength 共发布 44 个版本,首次发布于 2018/06/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
16.0.0latest2023/11/053 年前
13.0.02023/08/263 年前
12.1.02023/02/223 年前
12.0.22022/11/263 年前
12.0.12022/11/263 年前
11.0.12022/10/154 年前

关于 @angular-material-extensions/password-strength 的常见问题

@angular-material-extensions/password-strength 是什么?

显示密码的安全性的材料密码强度表

如何安装 @angular-material-extensions/password-strength?

在项目目录运行 npm install @angular-material-extensions/password-strength,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@angular/common(^16.x)、@angular/core(^16.x)、@angular/forms(^16.x)、@angular/cdk(^16.x)、@angular/material(^16.x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@angular-material-extensions/password-strength 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@angular-material-extensions/password-strength 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@angular-material-extensions/password-strength 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=14。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@angular-material-extensions/password-strength 可以商用吗?

@angular-material-extensions/password-strength 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@angular-material-extensions/password-strength 的下载量有多少?

根据 npm 官方下载统计,@angular-material-extensions/password-strength 在 2026/10/06 – 2026/11/04 这 30 天内被下载 31,320 次,日均约 1,044 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@angular-material-extensions/password-strength 还在维护吗?

最新版本 16.0.0 发布于 2023/11/05(3 年前);至今共发布 44 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/06/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。