1
0
Fork 0
mirror of https://github.com/Luzifer/vault2env.git synced 2024-12-20 12:11:19 +00:00
vault2env/obfuscator.go

29 lines
478 B
Go
Raw Permalink Normal View History

package main
import (
"crypto/sha256"
"fmt"
)
func replaceAsterisk(_, _ string) string { return "****" }
func replaceHash(_, secret string) string {
return fmt.Sprintf("sha256:%x", sha256.Sum256([]byte(secret)))
}
func replaceName(name, _ string) string { return name }
func getReplaceFn(name string) replaceFn {
switch name {
case "asterisk":
return replaceAsterisk
case "hash":
return replaceHash
case "name":
return replaceName
default:
return nil
}
}