File tree Expand file tree Collapse file tree 4 files changed +29
-14
lines changed Expand file tree Collapse file tree 4 files changed +29
-14
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ go 1.24.0
5
5
require (
6
6
github.com/charmbracelet/bubbletea v1.3.4
7
7
github.com/charmbracelet/lipgloss v1.0.0
8
+ golang.org/x/crypto v0.36.0
8
9
)
9
10
10
11
require (
@@ -20,7 +21,7 @@ require (
20
21
github.com/muesli/cancelreader v0.2.2 // indirect
21
22
github.com/muesli/termenv v0.15.2 // indirect
22
23
github.com/rivo/uniseg v0.4.7 // indirect
23
- golang.org/x/sync v0.11 .0 // indirect
24
- golang.org/x/sys v0.30 .0 // indirect
25
- golang.org/x/text v0.3.8 // indirect
24
+ golang.org/x/sync v0.12 .0 // indirect
25
+ golang.org/x/sys v0.31 .0 // indirect
26
+ golang.org/x/text v0.23.0 // indirect
26
27
)
Original file line number Diff line number Diff line change @@ -27,11 +27,13 @@ github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1n
27
27
github.com/rivo/uniseg v0.2.0 /go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc =
28
28
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ =
29
29
github.com/rivo/uniseg v0.4.7 /go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88 =
30
- golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w =
31
- golang.org/x/sync v0.11.0 /go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk =
30
+ golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34 =
31
+ golang.org/x/crypto v0.36.0 /go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc =
32
+ golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw =
33
+ golang.org/x/sync v0.12.0 /go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA =
32
34
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e /go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg =
33
35
golang.org/x/sys v0.6.0 /go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg =
34
- golang.org/x/sys v0.30 .0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc =
35
- golang.org/x/sys v0.30 .0 /go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA =
36
- golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY =
37
- golang.org/x/text v0.3.8 /go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ =
36
+ golang.org/x/sys v0.31 .0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik =
37
+ golang.org/x/sys v0.31 .0 /go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k =
38
+ golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY =
39
+ golang.org/x/text v0.23.0 /go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4 =
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
- "crypto/md5"
5
4
"encoding/hex"
6
5
"fmt"
7
6
"io"
8
7
"os"
8
+
9
+ "golang.org/x/crypto/blake2b"
9
10
)
10
11
11
12
func createFileHash (filePath string ) (string , error ) {
@@ -15,7 +16,11 @@ func createFileHash(filePath string) (string, error) {
15
16
}
16
17
defer file .Close ()
17
18
18
- hash := md5 .New ()
19
+ hash , err := blake2b .New256 (nil )
20
+ if err != nil {
21
+ return "" , fmt .Errorf ("failed to create BLAKE2b hash: %w" , err )
22
+ }
23
+
19
24
if _ , err := io .Copy (hash , file ); err != nil {
20
25
return "" , fmt .Errorf ("failed to compute hash: %w" , err )
21
26
}
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
- "crypto/md5"
5
4
"encoding/hex"
6
5
"io"
7
6
"os"
8
7
"path/filepath"
9
8
"testing"
9
+
10
+ "golang.org/x/crypto/blake2b"
10
11
)
11
12
12
13
func TestCreateFileHash (t * testing.T ) {
@@ -30,7 +31,10 @@ func TestCreateFileHash(t *testing.T) {
30
31
}
31
32
contentFile .Close ()
32
33
33
- h := md5 .New ()
34
+ h , err := blake2b .New256 (nil )
35
+ if err != nil {
36
+ t .Fatalf ("Failed to create BLAKE2b hash: %v" , err )
37
+ }
34
38
n , err := io .WriteString (h , content )
35
39
if err != nil {
36
40
t .Error (err )
@@ -40,7 +44,10 @@ func TestCreateFileHash(t *testing.T) {
40
44
}
41
45
expectedContentHash := hex .EncodeToString (h .Sum (nil ))
42
46
43
- emptyHash := md5 .New ()
47
+ emptyHash , err := blake2b .New256 (nil )
48
+ if err != nil {
49
+ t .Fatalf ("Failed to create BLAKE2b hash for empty file: %v" , err )
50
+ }
44
51
expectedEmptyHash := hex .EncodeToString (emptyHash .Sum (nil ))
45
52
46
53
tests := []struct {
You can’t perform that action at this time.
0 commit comments