推荐一个高灵活度js的密码生成器

235 阅读1分钟

这是一款本人开源字符串随机生成的插件,可用于生成任何长度的密码和/或字符串。它还允许自定义随机内容范围,并提供设置分隔符位置和符号的灵活性,不做任何特定规则或限制,目前有一定的下载量,欢迎大家使用。

install

npm install 5x-random-str

import

//commonjs
const rs5x = require("5x-random-str")

//es6+ 
import * as rs5x from "5x-random-str";

//iife
<script src="https://unpkg.com/5x-random-str/index.js"></script>
const rs5x = window["5x-random-str"];

simple default

rs5x.randomStr()
#result
a9ZOLl.@[7@K}RSA

use Number

rs5x.Number(12)
#result
280127374882

use ABC

rs5x.ABC(12)
#result
ZKVWGZYUAZSF

use abc

rs5x.abc(12)
#result
gcdglealiwyv

use ABC_abc

rs5x.ABC_abc(12)
#result
WbMaduuxDgfS

use ABC_abc_123

rs5x.ABC_abc_123()
#result
kPo4gsk5KAC6GoN5

use strongPasswd

rs5x.strongPasswd(12)
#result
#FIKz@bfMoHp

use superPasswd

rs5x.superPasswd()
#result
b,[NoxLTOV-c_1wT

use length,use default chats,use upperCase

rs5x.randomStr(20, [],  true)
#result
$C)5D})MBU*?U!~@.W!$

use chars array const

rs5x.randomStr(6, [rs5x.CHARS.ABC_XYZ,rs5x.CHARS.abc_xyz],  true)
#result
CGZUYF

use custom chars

rs5x.randomStr(1, ["甲乙丙丁戊己庚辛壬癸","尨"],  true)+rs5x.randomStr(1, ["子丑寅卯辰巳午未申酉戌亥"],  true)
#result
辛卯

use more chars

rs5x.randomStr(32, [    rs5x.CHARS["+.(~)[]?}|{][,-"],
    rs5x.CHARS["!@#$%^&*()_"]],  true)
#result
^.!)]-!,!{)&])(?[[#|.?]%~]}?}]])

use separator

rs5x.randomStr(32, [
    rs5x.CHARS.ABC_XYZ,
    rs5x.CHARS.abc_xyz,
    rs5x.CHARS["1234567890"]],  false,"-")
#result
6E33-cs8K-mGBW-kg0V-toxp-dFmf-isOB-zShf

use separator step

rs5x.randomStr(32, [
    rs5x.CHARS.ABC_XYZ,
    rs5x.CHARS.abc_xyz,
    rs5x.CHARS["1234567890"]],  true,"__",5)
#result
BATL6__LVCEU__OEKGY__AFZBT__UDZCK__PIR3G__B1

use separator steps

rs5x.randomStr(32, [
    rs5x.CHARS.ABC_XYZ,
    rs5x.CHARS.abc_xyz,
    rs5x.CHARS["1234567890"]],  false,"-",[4,4,4,8])
#result
xFWh-G1N8-lYcf-skfGREvM-MoKOo63d0PZK

Readme