hash

package
v1.0.52 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSNumber

func JSNumber[T constraints.Integer | constraints.Float](num T) T

JSNumber 转换成兼容JS的数值.

func NewSipHash64 added in v1.0.52

func NewSipHash64() hash.Hash64
Example
package main

import (
	"encoding/hex"
	"fmt"

	"github.com/xuender/kit/hash"
)

func main() {
	sum := hash.NewSipHash64()
	sum.Write([]byte("123"))
	fmt.Println(hex.EncodeToString(sum.Sum(nil)))

}
Output:

af3d7d6c86832982

func SipHash128

func SipHash128(data []byte) (uint64, uint64)

SipHash128 哈希.

Example
package main

import (
	"fmt"

	"github.com/xuender/kit/hash"
)

func main() {
	fmt.Println(hash.SipHash128([]byte("123")))

}
Output:

8693645449139915215 11618447955228391416

func SipHash32

func SipHash32(data []byte) uint32

SipHash32 32位哈希.

func SipHash64

func SipHash64(data []byte) uint64

SipHash64 哈希,和Google Guava的sipHash24相同.

Example
package main

import (
	"fmt"

	"github.com/xuender/kit/hash"
)

func main() {
	fmt.Println(hash.SipHash64([]byte("123")))

}
Output:

9379172312344772015

func SipHashHex

func SipHashHex(data []byte) string

SipHashHex 字符串.

Example
package main

import (
	"fmt"

	"github.com/xuender/kit/hash"
)

func main() {
	fmt.Println(hash.SipHashHex([]byte("123")))
}
Output:

af3d7d6c86832982

func SipHashNumber

func SipHashNumber(data []byte) uint64

SipHashNumber 兼容JS, 53位长度.

Example
package main

import (
	"fmt"

	"github.com/xuender/kit/hash"
)

func main() {
	fmt.Println(hash.SipHashNumber([]byte("123")))
}
Output:

2677888159399343

Types

This section is empty.

Jump to

Keyboard shortcuts

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