Browse Source

Add sha512-224sum

dtluna 1 month ago
parent
commit
b7af56dadf
3 changed files with 15 additions and 1 deletions
  1. 1
    1
      README.md
  2. 5
    0
      hashsum.go
  3. 9
    0
      sha512-224sum/sha512-224sum.go

+ 1
- 1
README.md View File

@@ -71,7 +71,7 @@ Utilities:
71 71
  * [x] `sha224sum`
72 72
  * [x] `sha256sum`
73 73
  * [x] `sha384sum`
74
- * [ ] `sha512-224sum`
74
+ * [x] `sha512-224sum`
75 75
  * [ ] `sha512-256sum`
76 76
  * [x] `sha512sum`
77 77
  * [ ] `sleep`

+ 5
- 0
hashsum.go View File

@@ -22,6 +22,7 @@ var SHA224Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{56})  (?P<filename>.*)$
22 22
 var SHA256Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{64})  (?P<filename>.*)$")
23 23
 var SHA384Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{96})  (?P<filename>.*)$")
24 24
 var SHA512Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{128})  (?P<filename>.*)$")
25
+var SHA512_224Regex = SHA224Regex
25 26
 
26 27
 // SumFunc is a type of function that computes a hash.Hash for data in io.Reader
27 28
 type SumFunc func(io.Reader) (hash.Hash, error)
@@ -57,6 +58,10 @@ func SHA512Sum(r io.Reader) (hash.Hash, error) {
57 58
 	return copyIntoHash(r, sha512.New())
58 59
 }
59 60
 
61
+func SHA512_224Sum(r io.Reader) (hash.Hash, error) {
62
+	return copyIntoHash(r, sha512.New512_224())
63
+}
64
+
60 65
 type CheckingResults struct {
61 66
 	ImproperlyFormattedCount uint
62 67
 	InvalidChecksumCount     uint

+ 9
- 0
sha512-224sum/sha512-224sum.go View File

@@ -0,0 +1,9 @@
1
+package main
2
+
3
+import (
4
+	common "source.heropunch.io/tomo/go-coreutils"
5
+)
6
+
7
+func main() {
8
+	common.SumMain(common.SHA512_224Regex, common.SHA512_224Sum)
9
+}

Loading…
Cancel
Save