mirror of
http://git.dtluna.net/tomo/go-coreutils.git
synced 2025-01-07 06:29:52 +00:00
Add sha256sum
This commit is contained in:
parent
65218af636
commit
3a636bfb4b
@ -69,7 +69,7 @@ Utilities:
|
||||
* [ ] `setsid`
|
||||
* [x] `sha1sum`
|
||||
* [x] `sha224sum`
|
||||
* [ ] `sha256sum`
|
||||
* [x] `sha256sum`
|
||||
* [ ] `sha384sum`
|
||||
* [ ] `sha512-224sum`
|
||||
* [ ] `sha512-256sum`
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
var MD5Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{32}) (?P<filename>.*)$")
|
||||
var SHA1Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{40}) (?P<filename>.*)$")
|
||||
var SHA224Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{56}) (?P<filename>.*)$")
|
||||
var SHA256Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{64}) (?P<filename>.*)$")
|
||||
|
||||
// SumFunc is a type of function that computes a hash.Hash for data in io.Reader
|
||||
type SumFunc func(io.Reader) (hash.Hash, error)
|
||||
@ -41,6 +42,10 @@ func SHA224Sum(r io.Reader) (hash.Hash, error) {
|
||||
return copyIntoHash(r, sha256.New224())
|
||||
}
|
||||
|
||||
func SHA256Sum(r io.Reader) (hash.Hash, error) {
|
||||
return copyIntoHash(r, sha256.New())
|
||||
}
|
||||
|
||||
type CheckingResults struct {
|
||||
ImproperlyFormattedCount uint
|
||||
InvalidChecksumCount uint
|
||||
|
9
sha256sum/sha256sum.go
Normal file
9
sha256sum/sha256sum.go
Normal file
@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
common "source.heropunch.io/tomo/go-coreutils"
|
||||
)
|
||||
|
||||
func main() {
|
||||
common.SumMain(common.SHA256Regex, common.SHA256Sum)
|
||||
}
|
Loading…
Reference in New Issue
Block a user