1
0
Fork 0
mirror of https://github.com/Luzifer/vault2env.git synced 2024-11-08 16:20:07 +00:00
vault2env/obfuscator.go
Knut Ahlers 2fb748b87a
Rewrite obfuscator logic not to work line-based
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2023-12-01 00:32:07 +01:00

28 lines
478 B
Go

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
}
}