types

package
v0.3.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TypeIs added in v0.3.3

func TypeIs(t Type, t2 Type) bool

Types

type Config

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

Config represents the configuration for hash algorithms

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig return to the default configuration

type HashParts

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

HashParts represents the parts of a hash

type Option added in v0.3.3

type Option func(*Config)

Option is a function that modifies a Config

func WithName added in v0.3.3

func WithName(name string) Option

func WithParams added in v0.2.14

func WithParams(paramConfig ParamConfig) Option

func WithParamsString added in v0.3.3

func WithParamsString(paramConfig string) Option

func WithSaltLength

func WithSaltLength(length int) Option

WithSaltLength sets the salt length

type ParamConfig added in v0.2.14

type ParamConfig interface {
	String() string
}

type Type

type Type string

Type represents the hash algorithm type

const (
	// TypeMD5 md5 type
	TypeMD5 Type = "md5"
	// TypeSha1 sha1 type
	TypeSha1 Type = "sha1"
	// TypeSha224 sha224 type
	TypeSha224 Type = "sha224"
	// TypeSha256 sha256 type
	TypeSha256 Type = "sha256"
	// TypeSha384 sha384 type
	TypeSha384 Type = "sha384"
	// TypeSha512 sha512 type
	TypeSha512 Type = "sha512"
	// TypeSha3224 sha3-224 type
	TypeSha3224 Type = "sha3-224"
	// TypeSha3256 sha3-256 type
	TypeSha3256 Type = "sha3-256"
	// TypeSha3384 sha3-384 type
	TypeSha3384 Type = "sha3-384"
	// TypeSha3512 sha3-512 type
	TypeSha3512 Type = "sha3-512"
	// TypeSha3512224 sha3-512-224 type
	TypeSha3512224 Type = "sha3-512-224"
	// TypeSha3512256 sha3-512-256 type
	TypeSha3512256 Type = "sha3-512-256"
	// TypeArgon2 argon2 type
	TypeArgon2 Type = "argon2"
	// TypeScrypt scrypt type
	TypeScrypt Type = "scrypt"
	// TypeBcrypt bcrypt type
	TypeBcrypt Type = "bcrypt"
	// TypeHMAC hmac type
	TypeHMAC Type = "hmac"
	// 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) Is added in v0.3.3

func (t Type) Is(t2 Type) bool

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