Documentation
¶
Index ¶
- Constants
- func Base64Decode(src string) (result string)
- func Base64EncodeByte(src []byte) string
- func Base64EncodeString(src string) string
- func CheckPassword(pw string, flag Flag, minLen int, maxLen ...int) bool
- func SHA(length int, content interface{}) (result string, err error)
- func Score(pwd string) int
- type Flag
- type MessageDigest
- type Password
Examples ¶
Constants ¶
View Source
const ( Letter = iota Digital Underline Characters )
View Source
const ( SHA1 = iota SHA256 SHA512 )
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶
func Base64EncodeByte ¶
func Base64EncodeString ¶
func CheckPassword ¶ added in v0.0.7
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
func SHA ¶
SHA implements several hash functions, including sha1, sha256, and sha512. Meanwhile, SHA supports file hash. When content type is string, it indicates the address of the file.
Example ¶
result, err := SHA(SHA1, []byte("hello world")) if err != nil { fmt.Println(err) return } fmt.Println(result) // output // 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
Output:
Types ¶
type Flag ¶ added in v0.0.7
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 )
type MessageDigest ¶
type MessageDigest string
func MD5 ¶
func MD5(src interface{}) (md MessageDigest, err error)
func (MessageDigest) LowerCase16 ¶
func (md MessageDigest) LowerCase16() string
func (MessageDigest) UpperCase16 ¶
func (md MessageDigest) UpperCase16() string
func (MessageDigest) UpperCase32 ¶
func (md MessageDigest) UpperCase32() string
type Password ¶
Click to show internal directories.
Click to hide internal directories.