From 577d5bf8fe51add28ad8ec1e3e740ca9d9567886 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 18 Dec 2017 09:46:11 -0800 Subject: [PATCH 1/2] include all hashes in algorithms list alternative to #54 --- opts/opts.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/opts/opts.go b/opts/opts.go index c905c9b..3f6c4f1 100644 --- a/opts/opts.go +++ b/opts/opts.go @@ -9,6 +9,7 @@ import ( "fmt" "io" "io/ioutil" + "sort" "strings" mh "github.com/multiformats/go-multihash" @@ -34,8 +35,15 @@ var FlagValues = struct { Encodings []string Algorithms []string }{ - Encodings: []string{"raw", "hex", "base58", "base64"}, - Algorithms: []string{"sha1", "sha2-256", "sha2-512", "sha3"}, + Encodings: []string{"raw", "hex", "base58", "base64"}, + Algorithms: func() []string { + names := make([]string, 0, len(mh.Names)) + for n := range mh.Names { + names = append(names, n) + } + sort.Strings(names) + return names + }(), } // SetupFlags adds multihash related options to given flagset. From c20bae2d9f1f1428b4dafe14b0db546a0c5f43e4 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 23 Aug 2018 19:10:29 -0700 Subject: [PATCH 2/2] cmd: filter out less-useful and non-implemented blake2 hash functions --- opts/opts.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/opts/opts.go b/opts/opts.go index 3f6c4f1..745c83f 100644 --- a/opts/opts.go +++ b/opts/opts.go @@ -39,6 +39,20 @@ var FlagValues = struct { Algorithms: func() []string { names := make([]string, 0, len(mh.Names)) for n := range mh.Names { + // There are too many of these for now. + // We can figure something better out later. + if strings.HasPrefix(n, "blake2") { + switch n { + case "blake2s-256": + case "blake2b-128": + case "blake2b-224": + case "blake2b-256": + case "blake2b-384": + case "blake2b-512": + default: + continue + } + } names = append(names, n) } sort.Strings(names)