password

package
v0.0.0-...-fbc1b07 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: Apache-2.0 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 password matches the format requirements.

Example
fmt.Println(CheckPassword("A", N|L_OR_U, 6))
fmt.Println(CheckPassword("a", N|L_OR_U, 6))
fmt.Println(CheckPassword("1", N|L_OR_U, 6))
fmt.Println(CheckPassword("Aa", N|L_OR_U, 6))
fmt.Println(CheckPassword("A1", N|L_OR_U, 6))
fmt.Println(CheckPassword("a1", N|L_OR_U, 6))
fmt.Println(CheckPassword("Aa1", N|L_OR_U, 6))
fmt.Println(CheckPassword("Aa12345", N|L_OR_U, 6))
fmt.Println(CheckPassword("AaBbCcDd", L|U, 6))
fmt.Println(CheckPassword("ABCD1234", N|U, 6))
fmt.Println(CheckPassword("abcd1234", N|L, 6, 7))
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
false
false
false
false
true
true
false
true
false

Types

type Flag

type Flag uint8

Flag password material requirement

const (
	// N Numbers
	N Flag = 1 << 0
	// L_OR_U Uppercase or lowercase letter
	L_OR_U Flag = 1 << 1
	// L Lowercase letters
	L Flag = 1 << 2
	// U Uppercase letter
	U Flag = 1 << 3
	// S Symbols found on the keyboard (all keyboard characters not defined as letters or 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