![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
check-password-strength
Advanced tools
A NPM Password strength checker based from Javascript RegExp. Check passphrase if it's "Too weak", "Weak", "Medium" or "Strong"
A simple way to check that password strength of a certain passphrase. The library is fully typed.
npm i check-password-strength --save
<script src="https://unpkg.com/check-password-strength/dist/umd.cjs"></script>
<script type="text/javascript">
const passwordStrength = checkPasswordStrength.passwordStrength('pwd123').value; // 'Weak'
</script>
const { passwordStrength } = require('check-password-strength')
// OR
import { passwordStrength } from 'check-password-strength'
console.log(passwordStrength('asdfasdf').value)
// Too weak (It will return Too weak if the value doesn't match the Weak conditions)
console.log(passwordStrength('asdf1234').value)
// Weak
console.log(passwordStrength('Asd1234!').value)
// Medium
console.log(passwordStrength('A@2asdF2020!!*').value)
// Strong
The passwordStrength
takes 3 arguments:
password
(string): the user passwordoptions
(array — optional): an option to override the default complexity required to match your password policy. See below.restrictSymbolsTo
(string — optional):
passwordStrength
function checks against all characters except for the 26 Latin lowercase letters, 26 uppercase letters, and 10 digits. This includes OWASP-recommended characters, accented letters, other alphabets, and emojis.[${escapeStringRegexp(restrictSymbolsTo)}]
.Password Default Options
The default options can be required:
const { defaultOptions } = require("./index");
// OR
import { defaultOptions } from 'check-password-strength'
default options:
[
{
id: 0,
value: "Too weak",
minDiversity: 0,
minLength: 0
},
{
id: 1,
value: "Weak",
minDiversity: 2,
minLength: 8
},
{
id: 2,
value: "Medium",
minDiversity: 4,
minLength: 10
},
{
id: 3,
value: "Strong",
minDiversity: 4,
minLength: 12
}
]
To override the default options, simply pass your custom array as the second argument:
You can use an array containing fewer or more than four items to define the levels of trust. However, the first element must have both the minDiversity and minLength parameters set to 0. This means that the first element should always represent a "too weak" option.
The result is an object containing the following values (unless you override the options
):
Property | Desc. |
---|---|
id | 0 = Too weak, 1 = Weak & 2 = Medium, 3 = Strong |
value | Too weak, Weak, Medium & Strong |
contains | lowercase, uppercase, number and / or symbol |
length | length of the password |
If you want to translate the value (Too weak → Trop faible), you can translate it based on the return value, or override the defaultOptions
option, which will be passed back as the function's return value.
Feel free to clone or fork this project: https://github.com/deanilvincent/check-password-strength.git
Contributions & pull requests are welcome!
I'll be glad if you give this project a ★ on Github :)
options
objectKudos to @Ennoriel and his efforts for making v2 and v3 possible!
FAQs
A NPM Password strength checker based from Javascript RegExp. Check passphrase if it's "Too weak", "Weak", "Medium" or "Strong"
The npm package check-password-strength receives a total of 22,188 weekly downloads. As such, check-password-strength popularity was classified as popular.
We found that check-password-strength demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.