mirror of
https://github.com/SSLMate/certspotter.git
synced 2025-06-27 10:15:33 +02:00
Add Compare to LogID and merkletree.Hash
This commit is contained in:
parent
d5bc1ef75b
commit
3279459be2
@ -10,6 +10,7 @@
|
|||||||
package cttypes
|
package cttypes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golang.org/x/crypto/cryptobyte"
|
"golang.org/x/crypto/cryptobyte"
|
||||||
@ -17,6 +18,10 @@ import (
|
|||||||
|
|
||||||
type LogID [32]byte
|
type LogID [32]byte
|
||||||
|
|
||||||
|
func (id LogID) Compare(other LogID) int {
|
||||||
|
return bytes.Compare(id[:], other[:])
|
||||||
|
}
|
||||||
|
|
||||||
func (v *LogID) Unmarshal(s *cryptobyte.String) bool {
|
func (v *LogID) Unmarshal(s *cryptobyte.String) bool {
|
||||||
return s.CopyBytes((*v)[:])
|
return s.CopyBytes((*v)[:])
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
package merkletree
|
package merkletree
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -20,6 +21,10 @@ const HashLen = 32
|
|||||||
|
|
||||||
type Hash [HashLen]byte
|
type Hash [HashLen]byte
|
||||||
|
|
||||||
|
func (h Hash) Compare(other Hash) int {
|
||||||
|
return bytes.Compare(h[:], other[:])
|
||||||
|
}
|
||||||
|
|
||||||
func (h Hash) Base64String() string {
|
func (h Hash) Base64String() string {
|
||||||
return base64.StdEncoding.EncodeToString(h[:])
|
return base64.StdEncoding.EncodeToString(h[:])
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user