metainfo: Add HashBytes
This commit is contained in:
parent
e0451b0728
commit
533f01147d
@ -1,6 +1,7 @@
|
|||||||
package metainfo
|
package metainfo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/sha1"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
@ -34,3 +35,10 @@ func (h *Hash) FromHexString(s string) (err error) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func HashBytes(b []byte) (ret Hash) {
|
||||||
|
hasher := sha1.New()
|
||||||
|
hasher.Write(b)
|
||||||
|
copy(ret[:], hasher.Sum(nil))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user