mirror of
http://git.dtluna.net/tomo/go-coreutils.git
synced 2025-01-07 06:29:52 +00:00
Add sha384sum
This commit is contained in:
parent
3a636bfb4b
commit
bf5b250df8
@ -70,7 +70,7 @@ Utilities:
|
||||
* [x] `sha1sum`
|
||||
* [x] `sha224sum`
|
||||
* [x] `sha256sum`
|
||||
* [ ] `sha384sum`
|
||||
* [x] `sha384sum`
|
||||
* [ ] `sha512-224sum`
|
||||
* [ ] `sha512-256sum`
|
||||
* [ ] `sha512sum`
|
||||
|
@ -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<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>.*)$")
|
||||
var SHA384Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{96}) (?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)
|
||||
@ -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
|
||||
|
9
sha384sum/sha384sum.go
Normal file
9
sha384sum/sha384sum.go
Normal file
@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
common "source.heropunch.io/tomo/go-coreutils"
|
||||
)
|
||||
|
||||
func main() {
|
||||
common.SumMain(common.SHA384Regex, common.SHA384Sum)
|
||||
}
|
Loading…
Reference in New Issue
Block a user