mirror of
https://github.com/Luzifer/vault2env.git
synced 2024-12-20 12:11:19 +00:00
28 lines
478 B
Go
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
|
|
}
|
|
}
|