Skip to content

Commit bc4c23b

Browse files
authored
Merge pull request #90 from infosiftr/sha256sum
Add `sha256sum` template function
2 parents 0b38175 + 1a4c6e8 commit bc4c23b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/templatelib/lib.go

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package templatelib
22

33
import (
4+
"crypto/sha256"
5+
"encoding/hex"
46
"encoding/json"
57
"fmt"
68
"os"
@@ -135,4 +137,10 @@ var FuncMap = template.FuncMap{
135137
return unsetVal
136138
}
137139
}),
140+
141+
// {{- sha256sum "hello world" -}}
142+
"sha256sum": func(input string) string {
143+
hash := sha256.Sum256([]byte(input))
144+
return hex.EncodeToString(hash[:])
145+
},
138146
}

0 commit comments

Comments
 (0)