password

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHAR_BRACE_START byte = '{'
	CHAR_BRACE_END   byte = '}'
	CHAR_DOLLAR      byte = '$'

	STR_BRACE_START string = "{"
	STR_BRACE_END   string = "}"
	STR_DOLLAR      string = ""
)

Variables

This section is empty.

Functions

func EncryptPassword

func EncryptPassword(pass string, alg PASSWORD_ALG) (string, error)

func EqualPassword

func EqualPassword(pass string, encryptPass string) bool

func GeneratePassword

func GeneratePassword() (string, error)

Types

type PASSWORD_ALG

type PASSWORD_ALG = string
const (
	PASSWORD_ALG_NOOP   PASSWORD_ALG = "noop"
	PASSWORD_ALG_BCRYPT PASSWORD_ALG = "bcrypt"
	PASSWORD_ALG_MD5    PASSWORD_ALG = "md5"
	PASSWORD_ALG_SHA256 PASSWORD_ALG = "sha256"
)

type PasswordEncoder

type PasswordEncoder interface {
	Alg() string
	Encrypt(pwd string) (string, error)

	// encryptPass without prefix
	Equal(pass string, encryptPass string) bool
	// contains filtered or unexported methods
}

func GetPasswordAlg

func GetPasswordAlg(encryptPass string) (PasswordEncoder, string)

{noop}password {bcrypt}$2a$10$IK/02aEUVRBaeoQsvN.VluPLqNKZ2ZwwTRmAAWXmlnCU5DAjmjtRC {MD5}5f4dcc3b5aa765d61d8327deb882cf99 {MD5}{L5M7tjEyGdBtyFCyk0pBXOLLFi3AOMEBZqdRDTAwV6c=}c05b48c699659f56462bbed387485cc6

func New

func New(_alg *string) (encoder PasswordEncoder)

alg string will not convert in this func, please use the right way default is bcrypt

Jump to

Keyboard shortcuts

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