Search…
Password Utilities
The Password Manager SDK provides utility methods to help generate strong passwords and calculate the strength of a password.

Generating Passwords

Help users adopt strong passwords by using the generatePassword method. Passwords are generated from a criteria of five different input options; length, allowUpperCase, allowLowercase, allowNumbers, and allowSymbols. By default, the generator will generate passwords of 20 characters, but will not allow a user to generate a password that is less than six characters. If all options are marked false, the password generator will apply all options, the same as if all options had been marked true, resulting in at least one character from each option.
TypeScript
Swift
Kotlin
1
// Generate a password
2
const password = client.generatePassword({
3
length: 20, // defaults to 20
4
allowUppercase: true,
5
allowLowercase: true,
6
allowNumbers: true,
7
allowSymbols: true,
8
})
Copied!
1
// Generate a password
2
let password = generatePassword(
3
length: 20, // defaults to 20
4
allowUppercase: true,
5
allowLowercase: true,
6
allowNumbers: true,
7
allowSymbols: true)
Copied!
1
// Generate a password
2
val password = generatePassword(
3
length = 20, // length defaults to 20
4
allowUppercase = true,
5
allowLowercase = true,
6
allowNumbers = true,
7
allowSymbols = true
8
)
Copied!
General criteria applied for generating passwords:
    Password length (>5)
    Uppercase (A-Z)
    Lowercase (a-z)
    Numbers (0-9)
    Symbols (! ? @ * . _ -)

Calculating a Password's Strength

Use calculateStrengthOfPassword to measure the strength of the user's password. A strength level from an enum containing five strength levels (VeryWeak, Weak, Moderate, Strong, VeryStrong) will be returned after measuring the password. The criteria is based on how easy the password is to guess. A VeryWeak result means the password is risky and too guessable while a VeryStrong result it is extremely difficult to guess and has strong protection from offline slow-hash attacks. Use this method to rate current passwords and encourage user's to adopt stronger passwords.
TypeScript
Swift
Kotlin
1
// Calculate strength of password
2
// This returns a `PasswordStrength`.
3
const strength = client.calculateStrengthOfPassword(password)
4
5
// PasswordStrength enum
6
enum PasswordStrength {
7
case VeryWeak
8
case Weak
9
case Moderate
10
case Strong
11
case VeryStrong
12
}
Copied!
1
// Calculate strength of password
2
let strength = calculateStrength(of: password) // returns a `PasswordStrength`
3
4
// PasswordStrength enum
5
public enum PasswordStrength {
6
case veryWeak
7
case weak
8
case moderate
9
case strong
10
case veryStrong
11
}
Copied!
1
// Calculate strength of password
2
val strength = calculateStrengthOfPassword(password)
3
when (strength) {
4
PasswordStrength.VeryWeak,
5
PasswordStrength.Weak -> println("Please choose a stronger password")
6
else -> {}
7
}
8
9
// PasswordStrength enum
10
enum class PasswordStrength {
11
VeryWeak,
12
Weak,
13
Moderate,
14
Strong,
15
VeryStrong,
16
}
Copied!
Last modified 8mo ago