crypto

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultParams = &argon2id.Params{
	Memory:      64 * 1024,
	Iterations:  3,
	Parallelism: 4,
	SaltLength:  16,
	KeyLength:   32,
}

Functions

func Base64Decode

func Base64Decode(s string) ([]byte, error)

func Base64Encode

func Base64Encode(data []byte) string

func DecryptAES

func DecryptAES(s string, key []byte) ([]byte, error)

func DecryptFileAES

func DecryptFileAES(inputPath, outputPath string, key []byte) error

func EncryptAES

func EncryptAES(plaintext, key []byte) (string, error)

func EncryptFileAES

func EncryptFileAES(inputPath, outputPath string, key []byte) error

func GenerateAES256Key

func GenerateAES256Key() ([]byte, error)

func GenerateHMAC

func GenerateHMAC(message, key []byte, algorithm HashAlgorithm) (string, error)

func GenerateKey

func GenerateKey(size int) ([]byte, error)

func GeneratePassword

func GeneratePassword(length int, hasSpecial, hasUppercase bool) (string, error)

func Hash

func Hash(input string, algorithm HashAlgorithm) (string, error)

func HashFile

func HashFile(inputPath string, algorithm HashAlgorithm) (string, error)

func HashPassword

func HashPassword(password string) (string, error)

func VerifyHMAC

func VerifyHMAC(message, key []byte, expected string, algorithm HashAlgorithm) (bool, error)

func VerifyPassword

func VerifyPassword(password, hash string) (bool, error)

Types

type HashAlgorithm

type HashAlgorithm string
const (
	HashSHA1     HashAlgorithm = "sha1"
	HashMD5      HashAlgorithm = "md5"
	HashSHA3_256 HashAlgorithm = "sha3-256"
	HashSHA3_512 HashAlgorithm = "sha3-512"
	HashSHA256   HashAlgorithm = "sha256"
	HashSHA512   HashAlgorithm = "sha512"
)

type MatchResult

type MatchResult struct {
	Pattern string  `json:"pattern"`
	Token   string  `json:"token"`
	Entropy float64 `json:"entropy"`
}

type PasswordAnalysis

type PasswordAnalysis struct {
	Entropy       float64       `json:"entropy"`
	CrackTime     string        `json:"crack_time"`
	MatchSequence []MatchResult `json:"match_sequence"`
}

func AnalyzePassword

func AnalyzePassword(password string) PasswordAnalysis

Jump to

Keyboard shortcuts

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