2018-11-28 19:25:11 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/sha256"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2023-11-30 23:32:07 +00:00
|
|
|
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 }
|
2018-11-28 19:25:11 +00:00
|
|
|
|
2023-11-30 23:32:07 +00:00
|
|
|
func getReplaceFn(name string) replaceFn {
|
|
|
|
switch name {
|
2018-11-28 19:25:11 +00:00
|
|
|
case "asterisk":
|
2023-11-30 23:32:07 +00:00
|
|
|
return replaceAsterisk
|
2018-11-28 19:25:11 +00:00
|
|
|
|
|
|
|
case "hash":
|
2023-11-30 23:32:07 +00:00
|
|
|
return replaceHash
|
2018-11-28 19:25:11 +00:00
|
|
|
|
|
|
|
case "name":
|
2023-11-30 23:32:07 +00:00
|
|
|
return replaceName
|
2018-11-28 19:25:11 +00:00
|
|
|
|
|
|
|
default:
|
2023-11-30 23:32:07 +00:00
|
|
|
return nil
|
2018-11-28 19:25:11 +00:00
|
|
|
}
|
|
|
|
}
|