Documentation
¶
Index ¶
- func Hashid(id uint64, minLength uint8, alphabet string) string
- func MapHashByte(input []byte) string
- func MapHashString(input string) string
- func Md5Byte(in []byte, b ...byte) string
- func Md5String(in string) string
- func Sha256Byte(data []byte) string
- func Sha256String(data string) string
- func UnHashid(hashedid string, minLength uint8, alphabet string) uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Hashid ¶
Hashid 使用sqids算法将数字ID编码为短哈希字符串。
参数:
- id: 要编码的数字ID
- minLength: 生成的哈希字符串最小长度
- alphabet: 自定义字母表(可选)
返回值:
- string: 编码后的哈希字符串
注意:
- 如果编码失败返回"ERROR"
- 默认使用sqids库的默认配置
func MapHashByte ¶ added in v1.3.2
func MapHashString ¶ added in v1.3.2
func Md5Byte ¶
Md5Byte 计算字节切片的MD5哈希值并返回十六进制字符串。
参数:
- in: 输入字节切片
- b: 可选的后缀字节(可省略)
返回值:
- string: 32字符的MD5哈希值(十六进制)
示例:
hash := Md5Byte([]byte("hello")) // 返回 "5d41402abc4b2a76b9719d911017c592"
hash := Md5Byte([]byte("hello"), '!') // 返回带后缀的哈希值
func Md5String ¶
Md5String 计算字符串的MD5哈希值并返回十六进制字符串。
参数:
- in: 输入字符串
返回值:
- string: 32字符的MD5哈希值(十六进制)
示例:
hash := Md5String("hello") // 返回 "5d41402abc4b2a76b9719d911017c592"
func Sha256Byte ¶ added in v1.3.2
func Sha256String ¶ added in v1.3.2
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.