encryption

package
v2.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: BSD-3-Clause Imports: 6 Imported by: 1 module, 10 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package encryption exposes functionalities needed for encryption and decryption operations in Bee.

Index

Constants

View Source
const (
	KeyLength     = 32
	ReferenceSize = 64
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChunkEncrypter

type ChunkEncrypter interface {
	EncryptChunk([]byte) (key Key, encryptedSpan, encryptedData []byte, err error)
}

ChunkEncrypter encrypts chunk data.

func NewChunkEncrypter

func NewChunkEncrypter() ChunkEncrypter

type Decrypter

type Decrypter interface {
	Key() Key
	Decrypt(data []byte) ([]byte, error)
}

type Encrypter

type Encrypter interface {
	Key() Key
	Encrypt(data []byte) ([]byte, error)
}

type Encryption

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

func (*Encryption) Decrypt

func (e *Encryption) Decrypt(data []byte) ([]byte, error)

Decrypt decrypts the data, if padding was used caller must know original length and truncate

func (*Encryption) Encrypt

func (e *Encryption) Encrypt(data []byte) ([]byte, error)

Encrypt encrypts the data and does padding if specified

func (*Encryption) Key

func (e *Encryption) Key() Key

Key returns the base key

func (*Encryption) Reset

func (e *Encryption) Reset()

Reset resets the counter. It is only safe to call after an encryption operation is completed After Reset is called, the Encryption object can be reused for other data

func (*Encryption) Transcrypt

func (e *Encryption) Transcrypt(i int, in, out []byte) error

used for segmentwise transformation if in is shorter than out, padding is used

type Interface

type Interface interface {
	Encrypter
	Decrypter
	Reset()
}

func New

func New(key Key, padding int, initCtr uint32, hashFunc func() hash.Hash) Interface

New constructs a new encrypter/decrypter

func NewDataEncryption

func NewDataEncryption(key Key) Interface

func NewSpanEncryption

func NewSpanEncryption(key Key) Interface

type Key

type Key []byte

func GenerateRandomKey

func GenerateRandomKey(l int) Key

GenerateRandomKey generates a random key of length l

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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