mirror of
http://git.dtluna.net/tomo/go-coreutils.git
synced 2025-01-07 06:19:54 +00:00
Add sha224sum
This commit is contained in:
parent
ece00da8dc
commit
65218af636
@ -68,7 +68,7 @@ Utilities:
|
||||
* [ ] `seq`
|
||||
* [ ] `setsid`
|
||||
* [x] `sha1sum`
|
||||
* [ ] `sha224sum`
|
||||
* [x] `sha224sum`
|
||||
* [ ] `sha256sum`
|
||||
* [ ] `sha384sum`
|
||||
* [ ] `sha512-224sum`
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"crypto/md5"
|
||||
"crypto/sha1"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
"hash"
|
||||
@ -16,6 +17,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>.*)$")
|
||||
|
||||
// SumFunc is a type of function that computes a hash.Hash for data in io.Reader
|
||||
type SumFunc func(io.Reader) (hash.Hash, error)
|
||||
@ -35,6 +37,10 @@ func SHA1Sum(r io.Reader) (hash.Hash, error) {
|
||||
return copyIntoHash(r, sha1.New())
|
||||
}
|
||||
|
||||
func SHA224Sum(r io.Reader) (hash.Hash, error) {
|
||||
return copyIntoHash(r, sha256.New224())
|
||||
}
|
||||
|
||||
type CheckingResults struct {
|
||||
ImproperlyFormattedCount uint
|
||||
InvalidChecksumCount uint
|
||||
|
9
sha224sum/sha224sum.go
Normal file
9
sha224sum/sha224sum.go
Normal file
@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
common "source.heropunch.io/tomo/go-coreutils"
|
||||
)
|
||||
|
||||
func main() {
|
||||
common.SumMain(common.SHA224Regex, common.SHA224Sum)
|
||||
}
|
Loading…
Reference in New Issue
Block a user