Browse Source

Add sha256sum

dtluna 1 month ago
parent
commit
3a636bfb4b
3 changed files with 15 additions and 1 deletions
  1. 1
    1
      README.md
  2. 5
    0
      hashsum.go
  3. 9
    0
      sha256sum/sha256sum.go

+ 1
- 1
README.md View File

@@ -69,7 +69,7 @@ Utilities:
69 69
  * [ ] `setsid`
70 70
  * [x] `sha1sum`
71 71
  * [x] `sha224sum`
72
- * [ ] `sha256sum`
72
+ * [x] `sha256sum`
73 73
  * [ ] `sha384sum`
74 74
  * [ ] `sha512-224sum`
75 75
  * [ ] `sha512-256sum`

+ 5
- 0
hashsum.go View File

@@ -18,6 +18,7 @@ import (
18 18
 var MD5Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{32})  (?P<filename>.*)$")
19 19
 var SHA1Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{40})  (?P<filename>.*)$")
20 20
 var SHA224Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{56})  (?P<filename>.*)$")
21
+var SHA256Regex = regexp.MustCompile("^(?P<hash>[0-9a-f]{64})  (?P<filename>.*)$")
21 22
 
22 23
 // SumFunc is a type of function that computes a hash.Hash for data in io.Reader
23 24
 type SumFunc func(io.Reader) (hash.Hash, error)
@@ -41,6 +42,10 @@ func SHA224Sum(r io.Reader) (hash.Hash, error) {
41 42
 	return copyIntoHash(r, sha256.New224())
42 43
 }
43 44
 
45
+func SHA256Sum(r io.Reader) (hash.Hash, error) {
46
+	return copyIntoHash(r, sha256.New())
47
+}
48
+
44 49
 type CheckingResults struct {
45 50
 	ImproperlyFormattedCount uint
46 51
 	InvalidChecksumCount     uint

+ 9
- 0
sha256sum/sha256sum.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.SHA256Regex, common.SHA256Sum)
9
+}

Loading…
Cancel
Save