Skip to content

Commit

Permalink
fix hash calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zebradil committed Apr 7, 2024
1 parent 4b6648e commit 6845a1e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,6 @@ golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 h1:6R2FC06FonbXQ8pK11/PDFY6N6LWlf9KlzibaCapmqc=
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ=
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw=
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down
3 changes: 1 addition & 2 deletions internal/myks/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ func sortYaml(yaml map[string]interface{}) (string, error) {
}

func hashString(s string) string {
fnv.New64a().Write([]byte(s))
return fmt.Sprintf("%x", fnv.New64a().Sum64())
return fmt.Sprintf("%x", fnv.New64a().Sum([]byte(s)))
}

func removeDirectory(dir string) error {
Expand Down
4 changes: 3 additions & 1 deletion internal/myks/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ func Test_hash(t *testing.T) {
b string
want string
}{
{"happy path", "some-string", "cbf29ce484222325"},
{"happy path", "some-string", "736f6d652d737472696e67cbf29ce484222325"},
{"happy path", "some-other-string", "736f6d652d6f746865722d737472696e67cbf29ce484222325"},
{"empty string", "", "cbf29ce484222325"},
}
for _, tt := range tests {
t.Run(tt.a, func(t *testing.T) {
Expand Down

0 comments on commit 6845a1e

Please sign in to comment.