diff --git a/README.md b/README.md index 83ee059..f4e6795 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Utilities: * [ ] `setsid` * [x] `sha1sum` * [x] `sha224sum` - * [ ] `sha256sum` + * [x] `sha256sum` * [ ] `sha384sum` * [ ] `sha512-224sum` * [ ] `sha512-256sum` diff --git a/hashsum.go b/hashsum.go index 9a6f3a1..1df396f 100644 --- a/hashsum.go +++ b/hashsum.go @@ -18,6 +18,7 @@ import ( var MD5Regex = regexp.MustCompile("^(?P[0-9a-f]{32}) (?P.*)$") var SHA1Regex = regexp.MustCompile("^(?P[0-9a-f]{40}) (?P.*)$") var SHA224Regex = regexp.MustCompile("^(?P[0-9a-f]{56}) (?P.*)$") +var SHA256Regex = regexp.MustCompile("^(?P[0-9a-f]{64}) (?P.*)$") // 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 diff --git a/sha256sum/sha256sum.go b/sha256sum/sha256sum.go new file mode 100644 index 0000000..6abd771 --- /dev/null +++ b/sha256sum/sha256sum.go @@ -0,0 +1,9 @@ +package main + +import ( + common "source.heropunch.io/tomo/go-coreutils" +) + +func main() { + common.SumMain(common.SHA256Regex, common.SHA256Sum) +}