types

package
v0.2.14 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SaltLength  int    `env:"HASH_SALTLENGTH"`
	ParamConfig string `env:"HASH_PARAM_CONFIG"`
}

Config represents the configuration for hash algorithms

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig 返回默认配置

type ConfigOption

type ConfigOption func(*Config)

ConfigOption is a function that modifies a Config

func WithParams added in v0.2.14

func WithParams(paramConfig ParamConfig) ConfigOption

func WithSaltLength

func WithSaltLength(length int) ConfigOption

WithSaltLength sets the salt length

type HashParts

type HashParts struct {
	Algorithm Type
	Version   string
	Params    string
	Hash      []byte
	Salt      []byte
}

HashParts represents the parts of a hash

type ParamConfig added in v0.2.14

type ParamConfig interface {
	String() string
}

type Type

type Type string

Type represents the hash algorithm type

const (
	// TypeCustom custom type
	TypeCustom Type = "custom"
	// TypeMD5 md5 type
	TypeMD5 Type = "md5"
	// TypeSha1 sha1 type
	TypeSha1 Type = "sha1"
	// TypeSha256 sha256 type
	TypeSha256 Type = "sha256"
	// TypeSha512 sha512 type
	TypeSha512 Type = "sha512"
	// TypeSha384 sha384 type
	TypeSha384 Type = "sha384"
	// TypeSha3256 sha3-256 type
	TypeSha3256 Type = "sha3-256"
	// TypeArgon2 argon2 type
	TypeArgon2 Type = "argon2"
	// TypeScrypt scrypt type
	TypeScrypt Type = "scrypt"
	// TypeBcrypt bcrypt type
	TypeBcrypt Type = "bcrypt"
	// TypeHMAC256 hmac sha256 type
	TypeHMAC256 Type = "hmac256"
	// TypeHMAC512 hmac sha512 type
	TypeHMAC512 Type = "hmac512"
	// TypePBKDF2 pbkdf2 type
	TypePBKDF2 Type = "pbkdf2"
	// TypePBKDF2SHA256 pbkdf2 sha256 type
	TypePBKDF2SHA256 Type = "pbkdf2-sha256"
	// TypePBKDF2SHA512 pbkdf2 sha512 type
	TypePBKDF2SHA512 Type = "pbkdf2-sha512"
	// TypePBKDF2SHA384 pbkdf2 sha384 type
	TypePBKDF2SHA384 Type = "pbkdf2-sha384"
	// TypePBKDF2SHA3256 pbkdf2 sha3-256 type
	TypePBKDF2SHA3256 Type = "pbkdf2-sha3-256"
	// TypePBKDF2SHA3224 pbkdf2 sha3-224 type
	TypePBKDF2SHA3224 Type = "pbkdf2-sha3-224"
	// TypePBKDF2SHA3384 pbkdf2 sha3-384 type
	TypePBKDF2SHA3384 Type = "pbkdf2-sha3-384"
	// TypePBKDF2SHA3512224 pbkdf2 sha3-512-224 type
	TypePBKDF2SHA3512224 Type = "pbkdf2-sha3-512-224"
	// TypePBKDF2SHA3512256 pbkdf2 sha3-512-256 type
	TypePBKDF2SHA3512256 Type = "pbkdf2-sha3-512-256"
	// TypePBKDF2SHA3512384 pbkdf2 sha3-512-384 type
	TypePBKDF2SHA3512384 Type = "pbkdf2-sha3-512-384"
	// TypePBKDF2SHA3512512 pbkdf2 sha3-512-512 type
	TypePBKDF2SHA3512512 Type = "pbkdf2-sha3-512-512"
	// TypeUnknown unknown type
	TypeUnknown Type = "unknown"
)

func ParseType

func ParseType(s string) Type

ParseType parses a string into a Type

func (Type) String

func (t Type) String() string

String returns the string representation of the type

Jump to

Keyboard shortcuts

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