|
|
@ -5,6 +5,7 @@ import ( |
|
|
|
"crypto/md5" |
|
|
|
"crypto/md5" |
|
|
|
"crypto/sha1" |
|
|
|
"crypto/sha1" |
|
|
|
"crypto/sha256" |
|
|
|
"crypto/sha256" |
|
|
|
|
|
|
|
"crypto/sha512" |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"hash" |
|
|
|
"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 SHA1Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{40}) (?P<filename>.*)$") |
|
|
|
var SHA224Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{56}) (?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 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
|
|
|
|
// SumFunc is a type of function that computes a hash.Hash for data in io.Reader
|
|
|
|
type SumFunc func(io.Reader) (hash.Hash, error) |
|
|
|
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()) |
|
|
|
return copyIntoHash(r, sha256.New()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func SHA384Sum(r io.Reader) (hash.Hash, error) { |
|
|
|
|
|
|
|
return copyIntoHash(r, sha512.New384()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type CheckingResults struct { |
|
|
|
type CheckingResults struct { |
|
|
|
ImproperlyFormattedCount uint |
|
|
|
ImproperlyFormattedCount uint |
|
|
|
InvalidChecksumCount uint |
|
|
|
InvalidChecksumCount uint |
|
|
|