-
Notifications
You must be signed in to change notification settings - Fork 0
/
lsh512.go
79 lines (64 loc) · 1.66 KB
/
lsh512.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package lsh512
import (
"hash"
)
const (
// The size of a LSH-512 checksum in bytes.
Size = 64
// The size of a LSH-512-224 checksum in bytes.
Size224 = 28
// The size of a LSH-512-256 checksum in bytes.
Size256 = 32
// The size of a LSH-384 checksum in bytes.
Size384 = 48
// The blocksize of LSH-512, LSH-384, LSH-512-256 and LSH-512-224 in bytes.
BlockSize = 256
)
// New returns a new hash.Hash computing the LSH-512 checksum.
func New() hash.Hash {
return newDigest(Size)
}
// New384 returns a new hash.Hash computing the LSH-384 checksum.
func New384() hash.Hash {
return newDigest(Size384)
}
// New256 returns a new hash.Hash computing the LSH-512-256 checksum.
func New256() hash.Hash {
return newDigest(Size256)
}
// New224 returns a new hash.Hash computing the LSH-512-224 checksum.
func New224() hash.Hash {
return newDigest(Size224)
}
// Sum returns the LSH-512 checksum of the data.
func Sum(data []byte) (sum512 [Size]byte) {
b := New()
b.Write(data)
sum := b.Sum(nil)
copy(sum512[:], sum)
return
}
// Sum384 returns the LSH-384 checksum of the data.
func Sum384(data []byte) (sum384 [Size384]byte) {
b := New()
b.Write(data)
sum := b.Sum(nil)
copy(sum384[:], sum)
return
}
// Sum256 returns the LSH-512-256 checksum of the data.
func Sum256(data []byte) (sum256 [Size256]byte) {
b := New()
b.Write(data)
sum := b.Sum(nil)
copy(sum256[:], sum)
return
}
// Sum224 returns the LSH-512-224 checksum of the data.
func Sum224(data []byte) (sum224 [Size224]byte) {
b := New()
b.Write(data)
sum := b.Sum(nil)
copy(sum224[:], sum)
return
}