security

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ZeroBytes

func ZeroBytes(data []byte)

ZeroBytes securely zeros out a byte slice to prevent sensitive data from remaining in memory. This uses explicit memory zeroing and garbage collection to help ensure the data is actually cleared.

func ZeroString

func ZeroString(s *string)

ZeroString securely clears a string reference and encourages garbage collection. Note: Go strings are immutable, so we can only clear the reference and rely on GC. This provides best-effort security by clearing the reference and forcing GC.

Types

type SecureBytes

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

SecureBytes is a wrapper for sensitive byte data that automatically zeros itself when no longer needed

func NewSecureBytes

func NewSecureBytes(data []byte) *SecureBytes

NewSecureBytes creates a new SecureBytes instance

func (*SecureBytes) Bytes

func (sb *SecureBytes) Bytes() []byte

Bytes returns the underlying byte slice (use with caution)

func (*SecureBytes) Clear

func (sb *SecureBytes) Clear()

Clear explicitly zeros the data and removes the finalizer

func (*SecureBytes) Copy

func (sb *SecureBytes) Copy() []byte

Copy returns a copy of the data

Jump to

Keyboard shortcuts

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