Merge pull request #90 from infosiftr/sha256sum
Add `sha256sum` template function
This commit is contained in:
commit
bc4c23b04c
|
|
@ -1,6 +1,8 @@
|
|||
package templatelib
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
|
@ -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[:])
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue