password

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2022 License: Apache-2.0, MIT Imports: 0 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(pw string, flag Flag, minLen int, maxLen ...int) bool

CheckPassword checks if the actual element of the password matches the expected flag.

Example
fmt.Println(CheckPassword("A", N|L_OR_U, 2))
fmt.Println(CheckPassword("a", N|L_OR_U, 2))
fmt.Println(CheckPassword("1", N|L_OR_U, 2))
fmt.Println(CheckPassword("Aa", N|L_OR_U, 2))
fmt.Println(CheckPassword("A1", N|L_OR_U, 2))
fmt.Println(CheckPassword("a1", N|L_OR_U, 2))
fmt.Println(CheckPassword("Aa1", N|L_OR_U, 2))
fmt.Println(CheckPassword("AaBbCcDd", L|U, 6))
fmt.Println(CheckPassword("ABCD1234", N|U, 6))
fmt.Println(CheckPassword("ABCD1234", N|L_OR_U|U, 6))
fmt.Println(CheckPassword("ABCD1234", N|L_OR_U|L, 6))
fmt.Println(CheckPassword("abcd1234", N|L, 6, 7))
fmt.Println(CheckPassword("Aa123456", N|L_OR_U, 6, 8))
fmt.Println(CheckPassword("Aa@123456", Flag(1<<6)|N|L|U|S, 6, 16))
fmt.Println(CheckPassword("Aa123456语言", N|L|U, 6))
Output:

false
false
false
false
true
true
true
true
true
true
false
false
true
true
false

Types

type Flag

type Flag uint8

Flag denotes the expected or actual element of the password.

const (
	// N denotes the numerals.
	N Flag = 1 << 0
	// L_OR_U denotes the lowercase or uppercase letters.
	L_OR_U Flag = 1 << 1
	// L denotes the lowercase letters.
	L Flag = 1 << 2
	// U denotes the uppercase letters.
	U Flag = 1 << 3
	// S denotes the printable symbols found on the keyboard, except letters, numerals and spaces.
	S Flag = 1 << 4
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL