hash

package
v0.0.0-...-4086ad0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeMode = NewTypeSet[Mode, string](maxMode)

Type Mode

View Source
var UseHash = NewDataSet[Mode, IHash]()

使用

Functions

func LeftCRCPadding

func LeftCRCPadding(text string, size int) string

CRC 左侧补码 0

func MD5_16

func MD5_16(s string) string

MD5_16

func RegisterHmacHash

func RegisterHmacHash(h HmacHash, f func() hash.Hash)

Types

type DataName

type DataName interface {
	~uint | ~int | ~string
}

type DataSet

type DataSet[N DataName, M any] struct {
	// contains filtered or unexported fields
}

*

  • 数据设置 *
  • @create 2023-3-31
  • @author deatil

func NewDataSet

func NewDataSet[N DataName, M any]() *DataSet[N, M]

构造函数

func (*DataSet[N, M]) Add

func (this *DataSet[N, M]) Add(name N, data func() M) *DataSet[N, M]

设置

func (*DataSet[N, M]) All

func (this *DataSet[N, M]) All() map[N]func() M

func (*DataSet[N, M]) Clean

func (this *DataSet[N, M]) Clean()

func (*DataSet[N, M]) Get

func (this *DataSet[N, M]) Get(name N) func() M

func (*DataSet[N, M]) Has

func (this *DataSet[N, M]) Has(name N) bool

func (*DataSet[N, M]) Len

func (this *DataSet[N, M]) Len() int

func (*DataSet[N, M]) Names

func (this *DataSet[N, M]) Names() []N

func (*DataSet[N, M]) Remove

func (this *DataSet[N, M]) Remove(name N) *DataSet[N, M]

删除

type Hash

type Hash struct {

	// 错误
	Error error
	// contains filtered or unexported fields
}

*

  • hash *
  • @create 2022-3-27
  • @author deatil

func FromBase64String

func FromBase64String(data string) Hash

FromBase64String

func FromBytes

func FromBytes(data []byte) Hash

字节

func FromHexString

func FromHexString(data string) Hash

FromHexString

func FromReader

func FromReader(reader io.Reader) Hash

FromReader

func FromString

func FromString(data string) Hash

字符

func Hashing

func Hashing() Hash

构造函数

func New

func New() Hash

构造函数

func NewHash

func NewHash() Hash

构造函数

func (Hash) Adler32

func (this Hash) Adler32() Hash

Adler32

func (Hash) Base64Decode

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

Base64 解码

func (Hash) Base64Encode

func (this Hash) Base64Encode(src []byte) string

Base64 编码

func (Hash) Blake224

func (this Hash) Blake224() Hash

Blake224 hash

func (Hash) Blake256

func (this Hash) Blake256() Hash

Blake256 hash

func (Hash) Blake2b_256

func (this Hash) Blake2b_256() Hash

Blake2b_256 哈希值

func (Hash) Blake2b_384

func (this Hash) Blake2b_384() Hash

Blake2b_384 哈希值

func (Hash) Blake2b_512

func (this Hash) Blake2b_512() Hash

Blake2b_512 哈希值

func (Hash) Blake2s_128

func (this Hash) Blake2s_128() Hash

Blake2s_128 哈希值

func (Hash) Blake2s_256

func (this Hash) Blake2s_256() Hash

Blake2s_256 哈希值

func (Hash) Blake384

func (this Hash) Blake384() Hash

Blake384 hash

func (Hash) Blake512

func (this Hash) Blake512() Hash

Blake512 hash

func (Hash) BlockSize

func (this Hash) BlockSize() int

BlockSize

func (Hash) CRC16_Modbus

func (this Hash) CRC16_Modbus() Hash

CRC16_Modbus 哈希值

func (Hash) CRC16_X25

func (this Hash) CRC16_X25() Hash

CRC16_X25 哈希值

func (Hash) CRC32_Castagnoli

func (this Hash) CRC32_Castagnoli() Hash

CRC32Castagnoli 哈希值

func (Hash) CRC32_IEEE

func (this Hash) CRC32_IEEE() Hash

CRC32IEEE 哈希值

func (Hash) CRC32_Koopman

func (this Hash) CRC32_Koopman() Hash

CRC32Koopman 哈希值

func (Hash) CRC64_ECMA

func (this Hash) CRC64_ECMA() Hash

CRC64ECMA 哈希值

func (Hash) CRC64_ISO

func (this Hash) CRC64_ISO() Hash

CRC64ISO

func (Hash) CShake128

func (this Hash) CShake128(N, S []byte, num int) Hash

CShake128 哈希值 num = 64

func (Hash) CShake256

func (this Hash) CShake256(N, S []byte, num int) Hash

CShake256 哈希值 num = 64

func (Hash) Checksum

func (this Hash) Checksum(h hash.Hash) Hash

CheckSum

func (Hash) Echo224

func (this Hash) Echo224() Hash

Echo224 哈希值

func (Hash) Echo256

func (this Hash) Echo256() Hash

Echo256 哈希值

func (Hash) Echo384

func (this Hash) Echo384() Hash

Echo384 哈希值

func (Hash) Echo512

func (this Hash) Echo512() Hash

Echo512 哈希值

func (Hash) Fnv128

func (this Hash) Fnv128() Hash

Fnv128

func (Hash) Fnv128a

func (this Hash) Fnv128a() Hash

Fnv128a

func (Hash) Fnv32

func (this Hash) Fnv32() Hash

Fnv32

func (Hash) Fnv32a

func (this Hash) Fnv32a() Hash

Fnv32a

func (Hash) Fnv64

func (this Hash) Fnv64() Hash

Fnv64

func (Hash) Fnv64a

func (this Hash) Fnv64a() Hash

Fnv64a

func (Hash) FromBase64String

func (this Hash) FromBase64String(data string) Hash

FromBase64String

func (Hash) FromBytes

func (this Hash) FromBytes(data []byte) Hash

字节

func (Hash) FromHexString

func (this Hash) FromHexString(data string) Hash

FromHexString

func (Hash) FromReader

func (this Hash) FromReader(reader io.Reader) Hash

FromReader

func (Hash) FromString

func (this Hash) FromString(data string) Hash

字符

func (Hash) FuncHash

func (this Hash) FuncHash(f func([]byte) ([]byte, error)) Hash

自定义方法

func (Hash) GetError

func (this Hash) GetError() error

GetError

func (Hash) Gost34112012

func (this Hash) Gost34112012(size int) Hash

gost34112012 签名

func (Hash) Gost34112012256

func (this Hash) Gost34112012256() Hash

gost34112012256 签名

func (Hash) Gost34112012512

func (this Hash) Gost34112012512() Hash

gost34112012512 签名

func (Hash) Gost341194

func (this Hash) Gost341194(cipher func([]byte) cipher.Block) Hash

gost341194 签名

func (Hash) HAS160

func (this Hash) HAS160() Hash

HAS160

func (Hash) Hash

func (this Hash) Hash() hash.Hash

Hash

func (Hash) HexDecode

func (this Hash) HexDecode(s string) ([]byte, error)

Hex 解码

func (Hash) HexEncode

func (this Hash) HexEncode(src []byte) string

Hex 编码

func (Hash) Hmac

func (this Hash) Hmac(h func() hash.Hash, secret []byte) Hash

Hmac HMAC (Hash-based Message Authentication Code) 常用于接口签名验证 支持的算法有: md5、sha1、sha256、sha512、adler32、crc32、crc32b、crc32c、 fnv132、fnv164、fnv1a32、fnv1a64、 gost、gost-crypto、haval128,3、haval128,4、haval128,5、 haval160,3、haval160,4、haval160,5、haval192,3、haval192,4、 haval192,5、haval224,3、haval224,4、haval224,5、haval256,3、 haval256,4、haval256,5、joaat、md2、md4、 ripemd128、ripemd160、ripemd256、ripemd320、 sha224、sha3-224、sha3-256、sha3-384、sha3-512、 sha384、sha512/224、sha512/256、 snefru、snefru256、tiger128,3、tiger128,4、tiger160,3、 tiger160,4、tiger192,3、tiger192,4、whirlpool

func (Hash) JH

func (this Hash) JH() Hash

国密 jh 签名

func (Hash) Keccak256

func (this Hash) Keccak256() Hash

Keccak256 哈希值

func (Hash) Keccak512

func (this Hash) Keccak512() Hash

Keccak512 哈希值

func (Hash) LSH256

func (this Hash) LSH256() Hash

LSH256

func (Hash) LSH256_224

func (this Hash) LSH256_224() Hash

LSH256_224

func (Hash) LSH512

func (this Hash) LSH512() Hash

LSH512

func (Hash) LSH512_224

func (this Hash) LSH512_224() Hash

LSH512_224

func (Hash) LSH512_256

func (this Hash) LSH512_256() Hash

LSH512_256

func (Hash) LSH512_384

func (this Hash) LSH512_384() Hash

LSH512_384

func (Hash) MD2

func (this Hash) MD2() Hash

md2 签名

func (Hash) MD4

func (this Hash) MD4() Hash

MD4 哈希值

func (Hash) MD5

func (this Hash) MD5() Hash

MD5

func (Hash) MD5SHA1

func (this Hash) MD5SHA1() Hash

MD5SHA1 哈希值

func (Hash) Maphash

func (this Hash) Maphash() Hash

Maphash

func (Hash) Murmur128

func (this Hash) Murmur128() Hash

murmur128

func (Hash) Murmur128WithSeed

func (this Hash) Murmur128WithSeed(seed uint32) Hash

murmur128

func (Hash) Murmur32

func (this Hash) Murmur32() Hash

murmur32

func (Hash) Murmur32WithSeed

func (this Hash) Murmur32WithSeed(seed uint32) Hash

murmur32

func (Hash) Murmur64

func (this Hash) Murmur64() Hash

murmur64

func (Hash) Murmur64WithSeed

func (this Hash) Murmur64WithSeed(seed uint32) Hash

murmur64

func (Hash) NewAdler32

func (this Hash) NewAdler32() Hash

NewAdler32

func (Hash) NewBlake224

func (this Hash) NewBlake224() Hash

NewBlake224

func (Hash) NewBlake256

func (this Hash) NewBlake256() Hash

NewBlake256

func (Hash) NewBlake2b_256

func (this Hash) NewBlake2b_256(key []byte) Hash

NewBlake2b_256

func (Hash) NewBlake2b_384

func (this Hash) NewBlake2b_384(key []byte) Hash

NewBlake2b_384

func (Hash) NewBlake2b_512

func (this Hash) NewBlake2b_512(key []byte) Hash

NewBlake2b_512

func (Hash) NewBlake2s_128

func (this Hash) NewBlake2s_128(key []byte) Hash

NewBlake2s_128

func (Hash) NewBlake2s_256

func (this Hash) NewBlake2s_256(key []byte) Hash

NewBlake2s_256

func (Hash) NewBlake384

func (this Hash) NewBlake384() Hash

NewBlake384

func (Hash) NewBlake512

func (this Hash) NewBlake512() Hash

NewBlake512

func (Hash) NewBy

func (this Hash) NewBy(name Mode, cfg ...any) Hash

New

func (Hash) NewCRC32_Castagnoli

func (this Hash) NewCRC32_Castagnoli() Hash

NewCRC32_Castagnoli

func (Hash) NewCRC32_IEEE

func (this Hash) NewCRC32_IEEE() Hash

NewCRC32_IEEE

func (Hash) NewCRC32_Koopman

func (this Hash) NewCRC32_Koopman() Hash

NewCRC32_Koopman

func (Hash) NewCRC64_ECMA

func (this Hash) NewCRC64_ECMA() Hash

NewCRC64_ECMA

func (Hash) NewCRC64_ISO

func (this Hash) NewCRC64_ISO() Hash

NewCRC64_ISO

func (Hash) NewCShake128

func (this Hash) NewCShake128(N, S []byte) Hash

NewCShake128

func (Hash) NewCShake256

func (this Hash) NewCShake256(N, S []byte) Hash

NewCShake256

func (Hash) NewEcho224

func (this Hash) NewEcho224() Hash

NewEcho224

func (Hash) NewEcho256

func (this Hash) NewEcho256() Hash

NewEcho256

func (Hash) NewEcho384

func (this Hash) NewEcho384() Hash

NewEcho384

func (Hash) NewEcho512

func (this Hash) NewEcho512() Hash

NewEcho512

func (Hash) NewFnv128

func (this Hash) NewFnv128() Hash

NewFnv128

func (Hash) NewFnv128a

func (this Hash) NewFnv128a() Hash

NewFnv128a

func (Hash) NewFnv32

func (this Hash) NewFnv32() Hash

NewFnv32

func (Hash) NewFnv32a

func (this Hash) NewFnv32a() Hash

NewFnv32a

func (Hash) NewFnv64

func (this Hash) NewFnv64() Hash

NewFnv64

func (Hash) NewFnv64a

func (this Hash) NewFnv64a() Hash

NewFnv64a

func (Hash) NewGost34112012

func (this Hash) NewGost34112012(size int) Hash

NewGost34112012

func (Hash) NewGost34112012256

func (this Hash) NewGost34112012256() Hash

NewGost34112012256

func (Hash) NewGost34112012512

func (this Hash) NewGost34112012512() Hash

NewGost34112012512

func (Hash) NewGost341194

func (this Hash) NewGost341194(cipher func([]byte) cipher.Block) Hash

NewGost341194

func (Hash) NewHAS160

func (this Hash) NewHAS160() Hash

NewHAS160

func (Hash) NewHash

func (this Hash) NewHash(h hash.Hash) Hash

NewHash

func (Hash) NewHmac

func (this Hash) NewHmac(h func() hash.Hash, secret []byte) Hash

NewHmac

func (Hash) NewJH

func (this Hash) NewJH() Hash

NewJH

func (Hash) NewKeccak256

func (this Hash) NewKeccak256() Hash

NewKeccak256

func (Hash) NewKeccak512

func (this Hash) NewKeccak512() Hash

NewKeccak512

func (Hash) NewLSH256

func (this Hash) NewLSH256() Hash

NewHAS160

func (Hash) NewLSH256_224

func (this Hash) NewLSH256_224() Hash

NewLSH256_224

func (Hash) NewLSH512

func (this Hash) NewLSH512() Hash

NewLSH512

func (Hash) NewLSH512_224

func (this Hash) NewLSH512_224() Hash

NewLSH512_224

func (Hash) NewLSH512_256

func (this Hash) NewLSH512_256() Hash

NewLSH512_256

func (Hash) NewLSH512_384

func (this Hash) NewLSH512_384() Hash

NewLSH512_384

func (Hash) NewMD2

func (this Hash) NewMD2() Hash

NewMD2

func (Hash) NewMD4

func (this Hash) NewMD4() Hash

NewMD4

func (Hash) NewMD5

func (this Hash) NewMD5() Hash

NewMD5

func (Hash) NewMaphash

func (this Hash) NewMaphash() Hash

NewMaphash

func (Hash) NewMurmur128

func (this Hash) NewMurmur128() Hash

NewMurmur128

func (Hash) NewMurmur128WithSeed

func (this Hash) NewMurmur128WithSeed(seed uint32) Hash

NewMurmur128WithSeed

func (Hash) NewMurmur32

func (this Hash) NewMurmur32() Hash

NewMurmur32

func (Hash) NewMurmur32WithSeed

func (this Hash) NewMurmur32WithSeed(seed uint32) Hash

NewMurmur32WithSeed

func (Hash) NewMurmur64

func (this Hash) NewMurmur64() Hash

NewMurmur64

func (Hash) NewMurmur64WithSeed

func (this Hash) NewMurmur64WithSeed(seed uint32) Hash

NewMurmur64WithSeed

func (Hash) NewRabin

func (this Hash) NewRabin(polynomial uint64, window int) Hash

NewRabin

func (Hash) NewRipemd160

func (this Hash) NewRipemd160() Hash

NewRipemd160

func (Hash) NewSHA1

func (this Hash) NewSHA1() Hash

NewSHA1

func (Hash) NewSHA224

func (this Hash) NewSHA224() Hash

NewSHA224

func (Hash) NewSHA256

func (this Hash) NewSHA256() Hash

NewSHA256

func (Hash) NewSHA384

func (this Hash) NewSHA384() Hash

NewSHA384

func (Hash) NewSHA3_224

func (this Hash) NewSHA3_224() Hash

NewSHA3_224

func (Hash) NewSHA3_256

func (this Hash) NewSHA3_256() Hash

NewSHA3_256

func (Hash) NewSHA3_384

func (this Hash) NewSHA3_384() Hash

NewSHA3_384

func (Hash) NewSHA3_512

func (this Hash) NewSHA3_512() Hash

NewSHA3_512

func (Hash) NewSHA512

func (this Hash) NewSHA512() Hash

NewSHA512

func (Hash) NewSHA512_224

func (this Hash) NewSHA512_224() Hash

NewSHA512_224

func (Hash) NewSHA512_256

func (this Hash) NewSHA512_256() Hash

NewSHA512_256

func (Hash) NewSM3

func (this Hash) NewSM3() Hash

NewSM3

func (Hash) NewShake128

func (this Hash) NewShake128() Hash

NewShake128

func (Hash) NewShake256

func (this Hash) NewShake256() Hash

NewShake256

func (Hash) NewSiphash128

func (this Hash) NewSiphash128(k []byte) Hash

NewSiphash128

func (Hash) NewSiphash64

func (this Hash) NewSiphash64(k []byte) Hash

NewSiphash64

func (Hash) NewSiphashWithCDroundsAndHashSize

func (this Hash) NewSiphashWithCDroundsAndHashSize(k []byte, crounds, drounds int32, hashSize int) Hash

NewSiphashWithCDroundsAndHashSize

func (Hash) NewTiger

func (this Hash) NewTiger() Hash

NewTiger

func (Hash) NewTiger2

func (this Hash) NewTiger2() Hash

NewTiger

func (Hash) NewWhirlpool

func (this Hash) NewWhirlpool() Hash

NewWhirlpool

func (Hash) NewXxhash32

func (this Hash) NewXxhash32() Hash

NewXxhash32

func (Hash) NewXxhash64

func (this Hash) NewXxhash64() Hash

NewXxhash64

func (Hash) Rabin

func (this Hash) Rabin(polynomial uint64, window int) Hash

国密 rabin 签名

func (Hash) Reset

func (this Hash) Reset() Hash

Reset

func (Hash) Ripemd160

func (this Hash) Ripemd160() Hash

Ripemd160 哈希值

func (Hash) SHA1

func (this Hash) SHA1() Hash

SHA1 哈希值

func (Hash) SHA224

func (this Hash) SHA224() Hash

SHA224 哈希值

func (Hash) SHA256

func (this Hash) SHA256() Hash

SHA256 哈希值

func (Hash) SHA384

func (this Hash) SHA384() Hash

SHA384 哈希值

func (Hash) SHA3_224

func (this Hash) SHA3_224() Hash

SHA3_224 哈希值

func (Hash) SHA3_256

func (this Hash) SHA3_256() Hash

SHA3_256 哈希值

func (Hash) SHA3_384

func (this Hash) SHA3_384() Hash

SHA3_384 哈希值

func (Hash) SHA3_512

func (this Hash) SHA3_512() Hash

SHA3_512 哈希值

func (Hash) SHA512

func (this Hash) SHA512() Hash

SHA512 哈希值

func (Hash) SHA512_224

func (this Hash) SHA512_224() Hash

SHA512_224 哈希值

func (Hash) SHA512_256

func (this Hash) SHA512_256() Hash

SHA512_256 哈希值

func (Hash) SM3

func (this Hash) SM3() Hash

国密 sm3 签名

func (Hash) Shake128

func (this Hash) Shake128(num int) Hash

Shake128 哈希值 num = 64

func (Hash) Shake256

func (this Hash) Shake256(num int) Hash

Shake256 哈希值 num = 64

func (Hash) Siphash128

func (this Hash) Siphash128(k []byte) Hash

Siphash128

func (Hash) Siphash64

func (this Hash) Siphash64(k []byte) Hash

Siphash64

func (Hash) SiphashWithCDroundsAndHashSize

func (this Hash) SiphashWithCDroundsAndHashSize(k []byte, crounds, drounds int32, hashSize int) Hash

SiphashWithCDroundsAndHashSize

func (Hash) Size

func (this Hash) Size() int

Size

func (Hash) String

func (this Hash) String() string

输出字符

func (Hash) Sum

func (this Hash) Sum(in []byte) Hash

Sum

func (Hash) Sum32

func (this Hash) Sum32() uint32

Sum32

func (Hash) Sum64

func (this Hash) Sum64() uint64

Sum64

func (Hash) SumBy

func (this Hash) SumBy(name Mode, cfg ...any) Hash

Sum

func (Hash) Tiger

func (this Hash) Tiger() Hash

Tiger

func (Hash) Tiger2

func (this Hash) Tiger2() Hash

Tiger

func (Hash) ToBase64String

func (this Hash) ToBase64String() string

输出Base64

func (Hash) ToBytes

func (this Hash) ToBytes() []byte

输出字节

func (Hash) ToHexString

func (this Hash) ToHexString() string

输出Hex

func (Hash) ToReader

func (this Hash) ToReader() io.Reader

输出 io.Reader

func (Hash) ToString

func (this Hash) ToString() string

输出字符

func (Hash) Whirlpool

func (this Hash) Whirlpool() Hash

Whirlpool

func (Hash) Write

func (this Hash) Write(p []byte) Hash

Write

func (Hash) WriteReader

func (this Hash) WriteReader(reader io.Reader) Hash

WriteReader

func (Hash) WriteString

func (this Hash) WriteString(s string) Hash

WriteString

func (Hash) Xxhash32

func (this Hash) Xxhash32() Hash

xxhash32 签名

func (Hash) Xxhash64

func (this Hash) Xxhash64() Hash

xxhash64 签名

type HmacHash

type HmacHash uint

hmac hash type

const (
	HmacADLER32 HmacHash = 1 + iota
	HmacMD2
	HmacMD4
	HmacMD5
	HmacSHA1
	HmacSHA224
	HmacSHA256
	HmacSHA384
	HmacSHA512
	HmacSHA512_224
	HmacSHA512_256
	HmacSHA3_224
	HmacSHA3_256
	HmacSHA3_384
	HmacSHA3_512
	HmacRIPEMD160
	HmacSM3
)

func (HmacHash) New

func (h HmacHash) New() hash.Hash

type IHash

type IHash interface {
	// Sum [输入内容, 其他配置]
	Sum(data []byte, cfg ...any) ([]byte, error)

	// New
	New(cfg ...any) (hash.Hash, error)
}

接口

type Mode

type Mode uint

Mode type

func (Mode) String

func (this Mode) String() string

type TypeName

type TypeName interface {
	~uint | ~int
}

Type Name

type TypeSet

type TypeSet[N TypeName, D any] struct {
	// contains filtered or unexported fields
}

Type Set

func NewTypeSet

func NewTypeSet[N TypeName, D any](max N) *TypeSet[N, D]

New TypeSet

func (*TypeSet[N, D]) Generate

func (this *TypeSet[N, D]) Generate() N

生成新序列 Generate new id

func (*TypeSet[N, D]) Names

func (this *TypeSet[N, D]) Names() *DataSet[N, D]

类型名称列表 name list

Directories

Path Synopsis
hashing