From 6ab823508659cf5fb2a67fc029cb981131eb80a8 Mon Sep 17 00:00:00 2001 From: comp500 Date: Mon, 29 May 2023 23:24:11 +0100 Subject: [PATCH] Change url add command to use sha256 (fixes #156) --- url/install.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/url/install.go b/url/install.go index d30cc77..8e9c233 100644 --- a/url/install.go +++ b/url/install.go @@ -57,9 +57,9 @@ var installCmd = &cobra.Command{ } } - hash, err := getSha1(args[1]) + hash, err := getHash(args[1]) if err != nil { - fmt.Println("Failed to retrieve SHA1 hash for file", err) + fmt.Println("Failed to retrieve SHA256 hash for file", err) os.Exit(1) } @@ -75,7 +75,7 @@ var installCmd = &cobra.Command{ FileName: filename, Download: core.ModDownload{ URL: args[1], - HashFormat: "sha1", + HashFormat: "sha256", Hash: hash, }, } @@ -123,9 +123,8 @@ var installCmd = &cobra.Command{ fmt.Printf("Successfully added %s (%s) from: %s\n", args[0], destPath, args[1]) }} -func getSha1(url string) (string, error) { - // TODO: hook up to existing cache system? might not be that useful - mainHasher, err := core.GetHashImpl("sha1") +func getHash(url string) (string, error) { + mainHasher, err := core.GetHashImpl("sha256") if err != nil { return "", err }