hashutil

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Description: 用於將文字雜湊化,並比較文字與雜湊後的文字是否相符

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHash

func CompareHash(textToCompare, hashedBase64, saltBase64 string, hashConfig ...HashConfig) bool

CompareHash 用於比較文字與雜湊後的文字是否相符,您可以傳入 HashConfig 結構體來設定雜湊的參數

func Hash

func Hash(text string, config ...HashConfig) (hashedBase64 string, saltBase64 string, err error)

Hash 用於將文字雜湊化,您可以傳入 HashConfig 結構體來設定雜湊的參數

Types

type HashConfig

type HashConfig struct {
	Memory     uint32 // 記憶體使用量,以 KB 為單位,預設值為 64 * 1024
	Iterations uint32 // 迭代次數,預設值為 3
	Threads    uint8  // 使用的執行緒數,預設值為 4
	CustomSalt []byte // 自訂鹽值,若未指定,則會自動生成
	SaltLength uint32 // 鹽值長度,當 CustomSalt 不為空時無效,預設值為 16
	KeyLength  uint32 // 雜湊後的字串長度,預設值為 32
}

HashConfig 用於設定雜湊的參數

Jump to

Keyboard shortcuts

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