diff --git a/README.md b/README.md index feb762e..a3bca9d 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Utilities: * [x] `sha384sum` * [ ] `sha512-224sum` * [ ] `sha512-256sum` - * [ ] `sha512sum` + * [x] `sha512sum` * [ ] `sleep` * [ ] `sort` * [ ] `split` diff --git a/hashsum.go b/hashsum.go index 8127ca0..ad40577 100644 --- a/hashsum.go +++ b/hashsum.go @@ -21,6 +21,7 @@ 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.*)$") var SHA384Regex = regexp.MustCompile("^(?P[0-9a-f]{96}) (?P.*)$") +var SHA512Regex = regexp.MustCompile("^(?P[0-9a-f]{128}) (?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) @@ -52,6 +53,10 @@ func SHA384Sum(r io.Reader) (hash.Hash, error) { return copyIntoHash(r, sha512.New384()) } +func SHA512Sum(r io.Reader) (hash.Hash, error) { + return copyIntoHash(r, sha512.New()) +} + type CheckingResults struct { ImproperlyFormattedCount uint InvalidChecksumCount uint diff --git a/sha512sum/sha512sum.go b/sha512sum/sha512sum.go new file mode 100644 index 0000000..cd06b20 --- /dev/null +++ b/sha512sum/sha512sum.go @@ -0,0 +1,9 @@ +package main + +import ( + common "source.heropunch.io/tomo/go-coreutils" +) + +func main() { + common.SumMain(common.SHA512Regex, common.SHA512Sum) +}