-
Notifications
You must be signed in to change notification settings - Fork 0
/
siphash.go
64 lines (46 loc) · 1.24 KB
/
siphash.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package hash
import (
"github.com/deatil/go-hash/siphash"
)
// Siphash64
func (this Hash) Siphash64(k []byte) Hash {
h := siphash.New64(k)
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewSiphash64
func (this Hash) NewSiphash64(k []byte) Hash {
this.hash = siphash.New64(k)
return this
}
// ==============
// Siphash128
func (this Hash) Siphash128(k []byte) Hash {
h := siphash.New128(k)
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewSiphash128
func (this Hash) NewSiphash128(k []byte) Hash {
this.hash = siphash.New128(k)
return this
}
// ==============
// SiphashWithCDroundsAndHashSize
func (this Hash) SiphashWithCDroundsAndHashSize(k []byte, crounds, drounds int32, hashSize int) Hash {
h, err := siphash.NewWithCDroundsAndHashSize(k, crounds, drounds, hashSize)
if err != nil {
this.Error = err
return this
}
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewSiphashWithCDroundsAndHashSize
func (this Hash) NewSiphashWithCDroundsAndHashSize(k []byte, crounds, drounds int32, hashSize int) Hash {
this.hash, this.Error = siphash.NewWithCDroundsAndHashSize(k, crounds, drounds, hashSize)
return this
}