Skip to content

Instantly share code, notes, and snippets.

@yano3nora
Created August 25, 2022 17:08
Show Gist options
  • Save yano3nora/9bc179b6a4a662efea3a48266e67054b to your computer and use it in GitHub Desktop.
Save yano3nora/9bc179b6a4a662efea3a48266e67054b to your computer and use it in GitHub Desktop.
[js: generate-password] #js

install

github.com/brendanashworth/generate-password

$ npm i generate-password

usage

Auth0のパスワードポリシーを満たすパスワード文字列をNode.js (generate-password) で生成する

// libs/password.ts

import { generate } from 'generate-password'

export const password = (length: number = 16) => generate({
  length,
  numbers: true, // 数値を含む
  symbols: true, // 記号を含む
  lowercase: true, // 英小文字含む
  uppercase: true, // 英大文字含む
  exclude: '()+_-=}{[]|:;"/?.><,`~', // 記号は !@#$%^&* のみ
  strict: true, // 各種文字列から最低 1 つずつ選定
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment