Documentation
¶
Index ¶
- Constants
- func CreateArgon2(cfg Argon2, password string) (string, error)
- func CreateBcrypt(cost int, password string) (string, error)
- func CreateMD5(str string) string
- func CreatePBKDF2(cfg PBKDF2, password string) (string, error)
- func CreateScrypt(cfg Scrypt, password string) (string, error)
- func VerifyArgon2(password, storedHash string) (bool, error)
- func VerifyBcrypt(password, storedHash string) bool
- func VerifyPBKDF2(password string, storedStr string) (bool, error)
- func VerifyScrypt(password, storedHash string) (bool, error)
- type Argon2
- type PBKDF2
- type Scrypt
Constants ¶
const DefaultSalt = "AwesomeGolangCrypto"
DefaultSalt is a global salt used across all hashing algorithms for additional security
Variables ¶
This section is empty.
Functions ¶
func CreateArgon2 ¶
CreateArgon2 generates an Argon2id hash for the given password using the provided configuration. Returns a base64-encoded string in format: salt:time:memory:threads:hash
func CreateBcrypt ¶
CreateBcrypt generates a bcrypt hash for the given password with the specified cost. Cost should be between 4 and 31, with 12-14 being recommended for most applications.
func CreateMD5 ¶
CreateMD5 creates an MD5 hash of the input string. WARNING: MD5 is cryptographically broken and should not be used for password hashing. This function is provided for legacy compatibility only.
func CreatePBKDF2 ¶
CreatePBKDF2 generates a PBKDF2 hash for the given password using the provided configuration. Returns a base64-encoded string in format: salt:iterations:hash
func CreateScrypt ¶
CreateScrypt generates a scrypt hash for the given password using the provided configuration. Returns a base64-encoded string in format: salt:N:r:p:hash
func VerifyArgon2 ¶
VerifyArgon2 verifies a password against a stored Argon2 hash
func VerifyBcrypt ¶
VerifyBcrypt verifies a password against a stored bcrypt hash
func VerifyPBKDF2 ¶
VerifyPBKDF2 verifies a password against a stored PBKDF2 hash
func VerifyScrypt ¶
VerifyScrypt verifies a password against a stored scrypt hash
Types ¶
type Argon2 ¶
type Argon2 struct {
// contains filtered or unexported fields
}
Argon2 configuration struct for Argon2id password hashing
func DefaultArgon2 ¶
func DefaultArgon2() Argon2
DefaultArgon2 returns an Argon2 configuration with secure default values
type PBKDF2 ¶
type PBKDF2 struct {
PBKDF2Iterations int // Number of iterations for key derivation
PBKDF2KeyLength int // Length of the derived key in bytes
SaltLength int // Length of the random salt in bytes
}
PBKDF2 configuration struct for PBKDF2 password hashing
func DefaultPBKDF2 ¶
func DefaultPBKDF2() PBKDF2
DefaultPBKDF2 returns a PBKDF2 configuration with secure default values
type Scrypt ¶
type Scrypt struct {
// contains filtered or unexported fields
}
Scrypt configuration struct for scrypt password hashing
func DefaultScrypt ¶
func DefaultScrypt() Scrypt
DefaultScrypt returns a Scrypt configuration with secure default values