Skip to content

Commit

Permalink
Merge pull request #20654 from hashicorp/b-filebase64sha256-sha512
Browse files Browse the repository at this point in the history
lang/funcs: Fix filebase64sha256 function hashing algorithm
  • Loading branch information
bflad authored Mar 12, 2019
2 parents 4de0b33 + 81bdaa8 commit 7a135c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lang/funcs/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var Base64Sha256Func = makeStringHashFunction(sha256.New, base64.StdEncoding.Enc
// MakeFileBase64Sha256Func constructs a function that is like Base64Sha256Func but reads the
// contents of a file rather than hashing a given literal string.
func MakeFileBase64Sha256Func(baseDir string) function.Function {
return makeFileHashFunction(baseDir, sha512.New, base64.StdEncoding.EncodeToString)
return makeFileHashFunction(baseDir, sha256.New, base64.StdEncoding.EncodeToString)
}

// Base64Sha512Func constructs a function that computes the SHA256 hash of a given string
Expand Down
6 changes: 3 additions & 3 deletions lang/funcs/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ func TestFileBase64Sha256(t *testing.T) {
}{
{
cty.StringVal("testdata/hello.txt"),
cty.StringVal("LHT9F+2v2A6ER7DUZ0HuJDt+t03SFJoKsbkkb7MDgvJ+hT2FhXGeDmfL2g2qj1FnEGRhXWRa4nrLFb+xRH9Fmw=="),
cty.StringVal("pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4="),
false,
},
{
cty.StringVal("testdata/icon.png"),
cty.StringVal("wSInO/tKEOaLGCAY2h/7gtLWMpzyLJ0ijFh95JTpYrPzXQYgviAdL9ZgpD9EAte8On+drvhFvjIFsfQUwxbNPQ=="),
cty.StringVal("47U1q9IZW093SmAzdC820Skpn8vHPvc8szud/Y3ezpo="),
false,
},
{
Expand All @@ -79,7 +79,7 @@ func TestFileBase64Sha256(t *testing.T) {
},
}

fileSHA256 := MakeFileBase64Sha512Func(".")
fileSHA256 := MakeFileBase64Sha256Func(".")

for _, test := range tests {
t.Run(fmt.Sprintf("filebase64sha256(%#v)", test.Path), func(t *testing.T) {
Expand Down

0 comments on commit 7a135c9

Please sign in to comment.