diff --git a/README.md b/README.md index f4e6795..feb762e 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Utilities: * [x] `sha1sum` * [x] `sha224sum` * [x] `sha256sum` - * [ ] `sha384sum` + * [x] `sha384sum` * [ ] `sha512-224sum` * [ ] `sha512-256sum` * [ ] `sha512sum` diff --git a/hashsum.go b/hashsum.go index 1df396f..8127ca0 100644 --- a/hashsum.go +++ b/hashsum.go @@ -5,6 +5,7 @@ import ( "crypto/md5" "crypto/sha1" "crypto/sha256" + "crypto/sha512" "errors" "fmt" "hash" @@ -19,6 +20,7 @@ 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.*)$") +var SHA384Regex = regexp.MustCompile("^(?P[0-9a-f]{96}) (?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) @@ -46,6 +48,10 @@ func SHA256Sum(r io.Reader) (hash.Hash, error) { return copyIntoHash(r, sha256.New()) } +func SHA384Sum(r io.Reader) (hash.Hash, error) { + return copyIntoHash(r, sha512.New384()) +} + type CheckingResults struct { ImproperlyFormattedCount uint InvalidChecksumCount uint diff --git a/sha384sum/sha384sum.go b/sha384sum/sha384sum.go new file mode 100644 index 0000000..228fb16 --- /dev/null +++ b/sha384sum/sha384sum.go @@ -0,0 +1,9 @@ +package main + +import ( + common "source.heropunch.io/tomo/go-coreutils" +) + +func main() { + common.SumMain(common.SHA384Regex, common.SHA384Sum) +}