21 lines
403 B
Go
21 lines
403 B
Go
package utils
|
|
|
|
import "fmt"
|
|
|
|
// MaskAPIKey masks an API key for safe logging.
|
|
func MaskAPIKey(key string) string {
|
|
length := len(key)
|
|
if length <= 8 {
|
|
return key
|
|
}
|
|
return fmt.Sprintf("%s****%s", key[:4], key[length-4:])
|
|
}
|
|
|
|
// TruncateString shortens a string to a maximum length.
|
|
func TruncateString(s string, maxLength int) string {
|
|
if len(s) > maxLength {
|
|
return s[:maxLength]
|
|
}
|
|
return s
|
|
}
|