Skip to content

Commit

Permalink
Merge pull request #90 from infosiftr/sha256sum
Browse files Browse the repository at this point in the history
Add `sha256sum` template function
  • Loading branch information
tianon authored Jan 22, 2024
2 parents 0b38175 + 1a4c6e8 commit bc4c23b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/templatelib/lib.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package templatelib

import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"os"
Expand Down Expand Up @@ -135,4 +137,10 @@ var FuncMap = template.FuncMap{
return unsetVal
}
}),

// {{- sha256sum "hello world" -}}
"sha256sum": func(input string) string {
hash := sha256.Sum256([]byte(input))
return hex.EncodeToString(hash[:])
},
}

0 comments on commit bc4c23b

Please sign in to comment.