securestring

package
v0.0.0-...-991afdd Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SecureString

type SecureString struct {
	// contains filtered or unexported fields
}

SecureString is used to store a string securely in memory. It uses memguard to protect sensitive data like passwords, API keys, etc. from being exposed in memory dumps, swap files, or other memory scanning attacks.

func NewSecureString

func NewSecureString(s string) (*SecureString, error)

NewSecureString creates a new SecureString instance from the given string. The original string should be cleared/wiped after creating SecureString to ensure the sensitive data is only stored in the secure buffer.

func (*SecureString) Bytes

func (ss *SecureString) Bytes() []byte

Bytes returns the byte representation of the securely stored string. WARNING: The returned bytes are still protected by memguard, but any copies made from this slice will not be protected. Use with caution.

func (*SecureString) String

func (ss *SecureString) String() string

String returns the securely stored string. WARNING: The returned string is a copy and will not be protected by memguard. Use this method carefully and wipe the string after use if possible.

func (*SecureString) Wipe

func (ss *SecureString) Wipe() error

Wipe removes the string from memory and makes it unrecoverable. After calling Wipe, the SecureString instance should not be used.

Jump to

Keyboard shortcuts

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