Browse Source

Add sha512-256sum

dtluna 8 months ago
parent
commit
5fc2672d64
3 changed files with 15 additions and 1 deletions
  1. 1
    1
      README.md
  2. 5
    0
      hashsum.go
  3. 9
    0
      sha512-256sum/sha512-256sum.go

+ 1
- 1
README.md View File

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

+ 5
- 0
hashsum.go View File

@@ -23,6 +23,7 @@ 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 25
 var SHA512_224Regex = SHA224Regex
26
+var SHA512_256Regex = SHA256Regex
26 27
 
27 28
 // SumFunc is a type of function that computes a hash.Hash for data in io.Reader
28 29
 type SumFunc func(io.Reader) (hash.Hash, error)
@@ -62,6 +63,10 @@ func SHA512_224Sum(r io.Reader) (hash.Hash, error) {
62 63
 	return copyIntoHash(r, sha512.New512_224())
63 64
 }
64 65
 
66
+func SHA512_256Sum(r io.Reader) (hash.Hash, error) {
67
+	return copyIntoHash(r, sha512.New512_256())
68
+}
69
+
65 70
 type CheckingResults struct {
66 71
 	ImproperlyFormattedCount uint
67 72
 	InvalidChecksumCount     uint

+ 9
- 0
sha512-256sum/sha512-256sum.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_256Regex, common.SHA512_256Sum)
9
+}

Loading…
Cancel
Save