memory

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package memory provides secure memory management utilities for handling sensitive data such as tokens, credentials, and other secrets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SecureBuffer

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

SecureBuffer represents a secure memory buffer for storing sensitive data. It provides automatic cleanup and protection against memory dumps.

func NewSecureBuffer

func NewSecureBuffer(data []byte) *SecureBuffer

NewSecureBuffer creates a new secure buffer with the given data. The data is copied into the buffer to ensure isolation.

func (*SecureBuffer) Bytes

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

Bytes returns a copy of the buffer's data. The returned slice is safe to use and modify.

func (*SecureBuffer) Clear

func (sb *SecureBuffer) Clear()

Clear securely wipes the buffer's memory by overwriting it with random data and then zeroing it out. After calling Clear(), the buffer should not be used.

func (*SecureBuffer) IsCleared

func (sb *SecureBuffer) IsCleared() bool

IsCleared returns true if the buffer has been cleared.

func (*SecureBuffer) Len

func (sb *SecureBuffer) Len() int

Len returns the length of the buffer.

func (*SecureBuffer) String

func (sb *SecureBuffer) String() string

String returns the buffer's data as a string. This creates a copy of the data, so the returned string is safe to use.

Jump to

Keyboard shortcuts

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