redact

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package redact provides utilities for redacting sensitive data.

Index

Constants

This section is empty.

Variables

View Source
var StringRedactor = func(s string) string {
	return MaskedString(s).String()
}

StringRedactor is the default redactor for strings.

Functions

func ContainsRedacted

func ContainsRedacted(x interface{}) bool

func SetEnabled

func SetEnabled(b bool)

SetEnabled can be used to toggle redact functionality.

func String

func String(s string) string

String returns redacted string.

func Value

func Value(v interface{}) interface{}

Value returns value with sensitive fields redacted. The value will return unchanged if it cannot be redacted.

Types

type MaskedString

type MaskedString string

MaskedString is a type that masks an actual string data. It implements fmt.Stringer and encoding.TextMarshaler for returning asterisks `*` characters with same length as the actual string value.

func (MaskedString) MarshalText

func (s MaskedString) MarshalText() (text []byte, err error)

func (MaskedString) Redacted

func (s MaskedString) Redacted() interface{}

func (MaskedString) String

func (s MaskedString) String() string

type Redactor

type Redactor interface {
	Redacted() interface{}
}

Redactor is an interface to be implemented by types that contain sensitive data that should be redacted. Redacted should return copy of the value with the sensitive fields redacted.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL