Documentation
¶
Overview ¶
Package core implements the functions, types, and interfaces for the module.
Package core implements the functions, types, and interfaces for the module.
Index ¶
- Constants
- Variables
- func AlgorithmTypeHash(algorithm types.Type) (types.Type, string)
- func IsCustomHash(h Hash) bool
- func NewCodec(algorithm types.Type, opts ...CodecOption) interfaces.Codec
- func NewMD5SHA1() hash.Hash
- func ParseParams(params string) (map[string]string, error)
- func RegisterHashFunc(name string, hashFunc func() hash.Hash)
- func RegisterOrUpdateHashFunc(name string, hashFunc func() hash.Hash)
- func UpdateHashFunc(hash Hash, hashFunc func() hash.Hash)
- type Codec
- type CodecOption
- type Hash
Constants ¶
View Source
const ( // ENV environment variable name ENV = "ORIGADMIN_HASH_TYPE" // DefaultType default hash type DefaultType = "argon2" // DefaultVersion default hash version DefaultVersion = "v1" // DefaultSaltLength default salt length DefaultSaltLength = 16 // DefaultTimeCost default time cost for Argon2 DefaultTimeCost = 3 // DefaultMemoryCost default memory cost for Argon2 DefaultMemoryCost = 64 * 1024 // 64MB // DefaultThreads default number of threads for Argon2 DefaultThreads = 4 // DefaultCost default cost for bcrypt DefaultCost = 10 ParamSeparator = "," ParamValueSeparator = ":" )
Variables ¶
View Source
var ( // ErrPasswordNotMatch error when password not match ErrPasswordNotMatch = errors.String("password not match") // ErrAlgorithmMismatch error when algorithm mismatch ErrAlgorithmMismatch = errors.String("algorithm mismatch") // ErrInvalidHashFormat error when invalid hash format ErrInvalidHashFormat = errors.String("invalid hash format") // ErrSaltLengthTooShort error when salt length too short ErrSaltLengthTooShort = errors.String("salt length must be at least 8 bytes") // ErrCostOutOfRange error when cost out of range ErrCostOutOfRange = errors.String("cost must be between 4 and 31") )
Functions ¶
func AlgorithmTypeHash ¶ added in v0.3.3
func IsCustomHash ¶ added in v0.2.14
func NewCodec ¶
func NewCodec(algorithm types.Type, opts ...CodecOption) interfaces.Codec
NewCodec creates a new codec
func NewMD5SHA1 ¶ added in v0.3.3
func RegisterHashFunc ¶ added in v0.2.14
RegisterHashFunc registers a new hash.Hash function
func RegisterOrUpdateHashFunc ¶ added in v0.2.14
RegisterOrUpdateHashFunc registers a new hash.Hash function if it does not exist, otherwise updates it
func UpdateHashFunc ¶ added in v0.2.14
UpdateHashFunc updates a hash.Hash function
Types ¶
type Codec ¶
type Codec struct {
// contains filtered or unexported fields
}
Codec implements a generic hash codec
type CodecOption ¶
type CodecOption func(*Codec)
CodecOption defines configuration options for the codec
type Hash ¶ added in v0.2.14
type Hash uint32
const ( MD4 Hash = 1 + iota // import golang.org/x/crypto/md4 MD5 // import crypto/md5 SHA1 // import crypto/sha1 SHA224 // import crypto/sha256 SHA256 // import crypto/sha256 SHA384 // import crypto/sha512 SHA512 // import crypto/sha512 MD5SHA1 // no implementation; MD5+SHA1 used for TLS RSA RIPEMD160 // import golang.org/x/crypto/ripemd160 SHA3_224 // import golang.org/x/crypto/sha3 SHA3_256 // import golang.org/x/crypto/sha3 SHA3_384 // import golang.org/x/crypto/sha3 SHA3_512 // import golang.org/x/crypto/sha3 SHA512_224 // import crypto/sha512 SHA512_256 // import crypto/sha512 BLAKE2s_256 // import golang.org/x/crypto/blake2s BLAKE2b_256 // import golang.org/x/crypto/blake2b BLAKE2b_384 // import golang.org/x/crypto/blake2b BLAKE2b_512 // import golang.org/x/crypto/blake2b ADLER32 CRC32 CRC32_ISO CRC32_CAST CRC32_KOOP CRC64_ISO CRC64_ECMA FNV32 FNV32A FNV64 FNV64A FNV128 FNV128A MAPHASH )
func ParseCryptoHash ¶ added in v0.2.14
ParseCryptoHash only deals with crypto.Hash supported algorithms
func ParseCustomHash ¶ added in v0.2.14
ParseCustomHash algorithms that handle custom registrations
func ParseInternalHash ¶ added in v0.2.14
ParseInternalHash algorithms that handle internal extensions
Click to show internal directories.
Click to hide internal directories.