github.com/fufuok/utils@v1.0.10/xhash/README.md (about) 1 <!-- Code generated by gomarkdoc. DO NOT EDIT --> 2 3 # xhash 4 5 ```go 6 import "github.com/fufuok/utils/xhash" 7 ``` 8 9 ## Index 10 11 - [func AddBytes32(h uint32, b []byte) uint32](<#func-addbytes32>) 12 - [func AddBytes64(h uint64, b []byte) uint64](<#func-addbytes64>) 13 - [func AddString32(h uint32, s string) uint32](<#func-addstring32>) 14 - [func AddString64(h uint64, s string) uint64](<#func-addstring64>) 15 - [func AddUint32(h, u uint32) uint32](<#func-adduint32>) 16 - [func AddUint64(h uint64, u uint64) uint64](<#func-adduint64>) 17 - [func Djb33(s string) uint32](<#func-djb33>) 18 - [func FnvHash(s string) uint64](<#func-fnvhash>) 19 - [func FnvHash32(s string) uint32](<#func-fnvhash32>) 20 - [func GenHasher[K comparable]() func(K) uintptr](<#func-genhasher>) 21 - [func GenHasher64[K comparable]() func(K) uint64](<#func-genhasher64>) 22 - [func GenSeedHasher64[K comparable]() func(maphash.Seed, K) uint64](<#func-genseedhasher64>) 23 - [func Hash(b []byte, h hash.Hash) []byte](<#func-hash>) 24 - [func HashBytes(b ...[]byte) string](<#func-hashbytes>) 25 - [func HashBytes32(b ...[]byte) uint32](<#func-hashbytes32>) 26 - [func HashBytes64(b ...[]byte) uint64](<#func-hashbytes64>) 27 - [func HashSeedString(seed maphash.Seed, s string) uint64](<#func-hashseedstring>) 28 - [func HashSeedUint64(seed maphash.Seed, n uint64) uint64](<#func-hashseeduint64>) 29 - [func HashString(s ...string) string](<#func-hashstring>) 30 - [func HashString32(s ...string) uint32](<#func-hashstring32>) 31 - [func HashString64(s ...string) uint64](<#func-hashstring64>) 32 - [func HashUint32(u uint32) uint32](<#func-hashuint32>) 33 - [func HashUint64(u uint64) uint64](<#func-hashuint64>) 34 - [func Hmac(b []byte, key []byte, h func() hash.Hash) []byte](<#func-hmac>) 35 - [func HmacSHA1(b, key []byte) []byte](<#func-hmacsha1>) 36 - [func HmacSHA1Hex(s, key string) string](<#func-hmacsha1hex>) 37 - [func HmacSHA256(b, key []byte) []byte](<#func-hmacsha256>) 38 - [func HmacSHA256Hex(s, key string) string](<#func-hmacsha256hex>) 39 - [func HmacSHA512(b, key []byte) []byte](<#func-hmacsha512>) 40 - [func HmacSHA512Hex(s, key string) string](<#func-hmacsha512hex>) 41 - [func MD5(b []byte) []byte](<#func-md5>) 42 - [func MD5BytesHex(bs []byte) string](<#func-md5byteshex>) 43 - [func MD5Hex(s string) string](<#func-md5hex>) 44 - [func MD5Reader(r io.Reader) (string, error)](<#func-md5reader>) 45 - [func MD5Sum(filename string) (string, error)](<#func-md5sum>) 46 - [func MemHash(s string) uint64](<#func-memhash>) 47 - [func MemHash32(s string) uint32](<#func-memhash32>) 48 - [func MemHashb(b []byte) uint64](<#func-memhashb>) 49 - [func MemHashb32(b []byte) uint32](<#func-memhashb32>) 50 - [func MustMD5Sum(filename string) string](<#func-mustmd5sum>) 51 - [func Sha1(b []byte) []byte](<#func-sha1>) 52 - [func Sha1Hex(s string) string](<#func-sha1hex>) 53 - [func Sha256(b []byte) []byte](<#func-sha256>) 54 - [func Sha256Hex(s string) string](<#func-sha256hex>) 55 - [func Sha512(b []byte) []byte](<#func-sha512>) 56 - [func Sha512Hex(s string) string](<#func-sha512hex>) 57 - [func Sum32(s string) uint32](<#func-sum32>) 58 - [func Sum64(s string) uint64](<#func-sum64>) 59 - [func SumBytes32(bs []byte) uint32](<#func-sumbytes32>) 60 - [func SumBytes64(bs []byte) uint64](<#func-sumbytes64>) 61 - [type Hashable](<#type-hashable>) 62 63 64 ## func AddBytes32 65 66 ```go 67 func AddBytes32(h uint32, b []byte) uint32 68 ``` 69 70 AddBytes32 adds the hash of b to the precomputed hash value h. Ref: segmentio/fasthash 71 72 ## func AddBytes64 73 74 ```go 75 func AddBytes64(h uint64, b []byte) uint64 76 ``` 77 78 AddBytes64 adds the hash of b to the precomputed hash value h. Ref: segmentio/fasthash 79 80 ## func AddString32 81 82 ```go 83 func AddString32(h uint32, s string) uint32 84 ``` 85 86 AddString32 adds the hash of s to the precomputed hash value h. Ref: segmentio/fasthash 87 88 ## func AddString64 89 90 ```go 91 func AddString64(h uint64, s string) uint64 92 ``` 93 94 AddString64 adds the hash of s to the precomputed hash value h. Ref: segmentio/fasthash 95 96 ## func AddUint32 97 98 ```go 99 func AddUint32(h, u uint32) uint32 100 ``` 101 102 AddUint32 adds the hash value of the 8 bytes of u to h. Ref: segmentio/fasthash 103 104 ## func AddUint64 105 106 ```go 107 func AddUint64(h uint64, u uint64) uint64 108 ``` 109 110 AddUint64 adds the hash value of the 8 bytes of u to h. Ref: segmentio/fasthash 111 112 ## func Djb33 113 114 ```go 115 func Djb33(s string) uint32 116 ``` 117 118 Djb33 比 FnvHash32 更快的获取字符串哈希值 djb2 with better shuffling. 5x faster than FNV with the hash.Hash overhead. Ref: patrickmn/go\-cache 119 120 ## func FnvHash 121 122 ```go 123 func FnvHash(s string) uint64 124 ``` 125 126 FnvHash 获取字符串的哈希值 127 128 ## func FnvHash32 129 130 ```go 131 func FnvHash32(s string) uint32 132 ``` 133 134 FnvHash32 获取字符串的哈希值 135 136 ## func GenHasher 137 138 ```go 139 func GenHasher[K comparable]() func(K) uintptr 140 ``` 141 142 ## func GenHasher64 143 144 ```go 145 func GenHasher64[K comparable]() func(K) uint64 146 ``` 147 148 GenHasher64 返回哈希函数 Ref: smallnest/safemap, alphadose/haxmap, cornelk/hashmap 149 150 ## func GenSeedHasher64 151 152 ```go 153 func GenSeedHasher64[K comparable]() func(maphash.Seed, K) uint64 154 ``` 155 156 ## func Hash 157 158 ```go 159 func Hash(b []byte, h hash.Hash) []byte 160 ``` 161 162 ## func HashBytes 163 164 ```go 165 func HashBytes(b ...[]byte) string 166 ``` 167 168 HashBytes 合并 Bytes, 得到字符串哈希 169 170 ## func HashBytes32 171 172 ```go 173 func HashBytes32(b ...[]byte) uint32 174 ``` 175 176 ## func HashBytes64 177 178 ```go 179 func HashBytes64(b ...[]byte) uint64 180 ``` 181 182 ## func HashSeedString 183 184 ```go 185 func HashSeedString(seed maphash.Seed, s string) uint64 186 ``` 187 188 HashSeedString calculates a hash of s with the given seed. 189 190 ## func HashSeedUint64 191 192 ```go 193 func HashSeedUint64(seed maphash.Seed, n uint64) uint64 194 ``` 195 196 HashSeedUint64 calculates a hash of n with the given seed. 197 198 ## func HashString 199 200 ```go 201 func HashString(s ...string) string 202 ``` 203 204 HashString 合并一串文本, 得到字符串哈希 205 206 ## func HashString32 207 208 ```go 209 func HashString32(s ...string) uint32 210 ``` 211 212 ## func HashString64 213 214 ```go 215 func HashString64(s ...string) uint64 216 ``` 217 218 ## func HashUint32 219 220 ```go 221 func HashUint32(u uint32) uint32 222 ``` 223 224 HashUint32 returns the hash of u. Ref: segmentio/fasthash 225 226 ## func HashUint64 227 228 ```go 229 func HashUint64(u uint64) uint64 230 ``` 231 232 HashUint64 returns the hash of u. Ref: segmentio/fasthash 233 234 ## func Hmac 235 236 ```go 237 func Hmac(b []byte, key []byte, h func() hash.Hash) []byte 238 ``` 239 240 ## func HmacSHA1 241 242 ```go 243 func HmacSHA1(b, key []byte) []byte 244 ``` 245 246 ## func HmacSHA1Hex 247 248 ```go 249 func HmacSHA1Hex(s, key string) string 250 ``` 251 252 ## func HmacSHA256 253 254 ```go 255 func HmacSHA256(b, key []byte) []byte 256 ``` 257 258 ## func HmacSHA256Hex 259 260 ```go 261 func HmacSHA256Hex(s, key string) string 262 ``` 263 264 ## func HmacSHA512 265 266 ```go 267 func HmacSHA512(b, key []byte) []byte 268 ``` 269 270 ## func HmacSHA512Hex 271 272 ```go 273 func HmacSHA512Hex(s, key string) string 274 ``` 275 276 ## func MD5 277 278 ```go 279 func MD5(b []byte) []byte 280 ``` 281 282 ## func MD5BytesHex 283 284 ```go 285 func MD5BytesHex(bs []byte) string 286 ``` 287 288 ## func MD5Hex 289 290 ```go 291 func MD5Hex(s string) string 292 ``` 293 294 MD5Hex 字符串 MD5 295 296 ## func MD5Reader 297 298 ```go 299 func MD5Reader(r io.Reader) (string, error) 300 ``` 301 302 MD5Reader 计算 MD5 303 304 ## func MD5Sum 305 306 ```go 307 func MD5Sum(filename string) (string, error) 308 ``` 309 310 MD5Sum 文件 MD5 311 312 ## func MemHash 313 314 ```go 315 func MemHash(s string) uint64 316 ``` 317 318 MemHash 使用内置的 memhash 获取字符串哈希值 319 320 ## func MemHash32 321 322 ```go 323 func MemHash32(s string) uint32 324 ``` 325 326 MemHash32 使用内置的 memhash 获取字符串哈希值 327 328 ## func MemHashb 329 330 ```go 331 func MemHashb(b []byte) uint64 332 ``` 333 334 MemHashb 使用内置的 memhash 获取哈希值 335 336 ## func MemHashb32 337 338 ```go 339 func MemHashb32(b []byte) uint32 340 ``` 341 342 MemHashb32 使用内置的 memhash 获取哈希值 343 344 ## func MustMD5Sum 345 346 ```go 347 func MustMD5Sum(filename string) string 348 ``` 349 350 ## func Sha1 351 352 ```go 353 func Sha1(b []byte) []byte 354 ``` 355 356 ## func Sha1Hex 357 358 ```go 359 func Sha1Hex(s string) string 360 ``` 361 362 ## func Sha256 363 364 ```go 365 func Sha256(b []byte) []byte 366 ``` 367 368 ## func Sha256Hex 369 370 ```go 371 func Sha256Hex(s string) string 372 ``` 373 374 ## func Sha512 375 376 ```go 377 func Sha512(b []byte) []byte 378 ``` 379 380 ## func Sha512Hex 381 382 ```go 383 func Sha512Hex(s string) string 384 ``` 385 386 ## func Sum32 387 388 ```go 389 func Sum32(s string) uint32 390 ``` 391 392 Sum32 获取字符串的哈希值 393 394 ## func Sum64 395 396 ```go 397 func Sum64(s string) uint64 398 ``` 399 400 Sum64 获取字符串的哈希值 401 402 ## func SumBytes32 403 404 ```go 405 func SumBytes32(bs []byte) uint32 406 ``` 407 408 SumBytes32 获取 bytes 的哈希值 409 410 ## func SumBytes64 411 412 ```go 413 func SumBytes64(bs []byte) uint64 414 ``` 415 416 SumBytes64 获取 bytes 的哈希值 417 418 ## type Hashable 419 420 Hashable allowed map key types constraint 421 422 ```go 423 type Hashable interface { 424 // contains filtered or unexported methods 425 } 426 ``` 427 428 429 430 Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)