# generate-password **Repository Path**: mirrors_jaywcjlove/generate-password ## Basic Information - **Project Name**: generate-password - **Description**: Generate Password is a generating random and unique passwords. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-06-16 - **Last Updated**: 2025-10-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Generate Password [](https://jaywcjlove.github.io/#/sponsor)  [](https://www.npmjs.com/package/@wcj/generate-password) [](https://github.com/jaywcjlove/generate-password/actions/workflows/ci.yml) [](https://jaywcjlove.github.io/generate-password/lcov-report/) [](https://bundlephobia.com/result?p=@wcj/generate-password) Generate Password is a generating random and unique passwords. ## Install ```bash $ npm install @wcj/generate-password --save ``` ## Usage ```js import { generate, generateMultiple, validate } from '@wcj/generate-password'; generate(); // => dK0#vA3@fG generate({ length: 23 }); // => bB1@aO7^bF0!aA0~aQ1%aE3 generateMultiple(2, { length: 8 }); // => [ 'aG6@aC2(', 'dH0{fQ0%' ] validate('qK0#dQ3*gG'); // => 4 Strong :) Now it's safe! ``` Or manually download and link **generate-password.js** in your HTML, It can also be downloaded via [UNPKG](https://unpkg.com/browse/@wcj/generate-password/): CDN: [UNPKG](https://unpkg.com/browse/@wcj/generate-password/) | [jsDelivr](https://cdn.jsdelivr.net/npm/@wcj/generate-password/) ```html ``` ## API ### generate Create a random password ```js import { generate } from '@wcj/generate-password'; generate(); // => dK0#vA3@fG generate({ length: 23 }); // => bB1@aO7^bF0!aA0~aQ1%aE3 generate({ upperCase: false }); // => n6[a3_f0$k generate({ lowerCase: false }); // => N0(B3,C4$I generate({ numeric: false }); // => cX*rB|jP:j generate({ numeric: false }); // => eD3rA0gL1b generate({ special: false, numeric: false }); // => aCaLlGfSgI generate({ special: false, lowerCase: false, upperCase: false }); // => 4020810127 generate({ special: false, lowerCase: false, numeric: false }); // => DEEBBCBYAO generate({ lowerCase: false, upperCase: false, numeric: false }); // => !%:#_#*&^! ``` ### generateMultiple Create a random set of passwords ```js import { generateMultiple } from '@wcj/generate-password'; generateMultiple(); // [ // 'qK0#dQ3*gG', 'rQ1#lB0#kE', 'mO1#dH1_tQ', 'gE1$rE2)aJ', // 'eR6#eJ5|qE', 'rP3!cH1)aK', 'iE0#dB2$iE', 'bC0&mI1#hB', // 'kB0(eG1!lD', 'bA7>hE4)kA' // ] generateMultiple(2, { length: 8 }); // => [ 'aG6@aC2(', 'dH0{fQ0%' ] ``` ### validate symbols pass with lowercase and uppercase letters, numbers and special characters ```js import { validate } from '@wcj/generate-password'; validate('qK0#dQ3*gG'); // => 4 Strong :) Now it's safe! validate('n6[a3_f0$k'); // => 3 Medium level. Enter more symbols! validate('aCaLlGfSgI'); // => 2 Very Weak! It's easy to crack! validate('4020810127'); // => 1 It's easy to crack! validate(); // => 0 ``` ## Options ```ts export declare const LOWERCASE = 'abcdefghijklmnopqrstuvwxyz'; export declare const UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; export declare const NUMERIC = '0123456789'; export declare const SPECIAL_CHARACTER = '!@#$%^&*()_+~`|}{\\[\\]:;?>,.<-=\\/'; export declare type Option = { /** * Integer, length of password. * @default 10 */ length?: number; /** Boolean, put lowercase in password */ lowerCase?: boolean; /** Boolean, use uppercase letters in password. */ upperCase?: boolean; /** Boolean, put numbers in password. */ numeric?: boolean; /** Special characters */ special?: boolean; }; /** Create a random password */ export declare function generate(opts?: Option): string; /** Create a random set of passwords */ export declare function generateMultiple(length?: number, opts?: Option): string[]; /** * symbols pass with lowercase and uppercase letters, numbers and special characters * @return [0~4] * * `4` Strong :) Now it's safe! * `3` Medium level. Enter more symbols! * `2` Very Weak! It's easy to crack! * `1` It's easy to crack! */ export declare function validate(password?: string): number; ``` ## Example ```jsx mdx:preview import React, { useState } from 'react'; import { generate } from '@wcj/generate-password'; const Demo = () => { const [lowerCase, setLowerCase] = useState(true); const [upperCase, setUpperCase] = useState(true); const [numeric, setNumeric] = useState(true); const [special, setSpecial] = useState(true); const [length, setLength] = useState(8); const opts = { lowerCase, upperCase, numeric, special, length }; const [password, setPassword] = useState(generate(opts)); return (