rc4

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package rc4 implements RC4 encryption and decryption with streaming support

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStreamDecrypter

func NewStreamDecrypter(r io.Reader, key []byte) io.Reader

NewStreamDecrypter returns a new RC4 stream decrypter

func NewStreamEncrypter

func NewStreamEncrypter(w io.Writer, key []byte) io.WriteCloser

NewStreamEncrypter returns a new RC4 stream encrypter

Types

type KeySizeError

type KeySizeError int

KeySizeError represents an error when the RC4 key size is invalid. RC4 keys must be between 1 and 256 bytes long. This error occurs when the provided key does not meet these size requirements.

func (KeySizeError) Error

func (k KeySizeError) Error() string

Error returns a formatted error message describing the invalid key size. The message includes the actual key size and the required size range for debugging.

type ReadError

type ReadError struct {
	Err error // The underlying error that caused the failure
}

ReadError represents an error when reading encrypted data fails. This error occurs when reading encrypted data from the underlying reader fails. The error includes the underlying error for detailed debugging.

func (ReadError) Error

func (e ReadError) Error() string

Error returns a formatted error message describing the read failure. The message includes the underlying error for debugging.

type StdDecrypter

type StdDecrypter struct {
	Error error
	// contains filtered or unexported fields
}

StdDecrypter represents an RC4 decrypter

func NewStdDecrypter

func NewStdDecrypter(key []byte) *StdDecrypter

NewStdDecrypter returns a new RC4 decrypter

func (*StdDecrypter) Decrypt

func (d *StdDecrypter) Decrypt(src []byte) (dst []byte, err error)

Decrypt decrypts src using RC4

type StdEncrypter

type StdEncrypter struct {
	Error error
	// contains filtered or unexported fields
}

StdEncrypter represents an RC4 encrypter

func NewStdEncrypter

func NewStdEncrypter(key []byte) *StdEncrypter

NewStdEncrypter returns a new RC4 encrypter

func (*StdEncrypter) Encrypt

func (e *StdEncrypter) Encrypt(src []byte) (dst []byte, err error)

Encrypt encrypts src using RC4

type StreamDecrypter

type StreamDecrypter struct {
	Error error
	// contains filtered or unexported fields
}

StreamDecrypter implements io.Reader interface for streaming RC4 decryption

func (*StreamDecrypter) Read

func (d *StreamDecrypter) Read(p []byte) (n int, err error)

Read implements io.Reader interface

type StreamEncrypter

type StreamEncrypter struct {
	Error error
	// contains filtered or unexported fields
}

StreamEncrypter implements io.WriteCloser interface for streaming RC4 encryption

func (*StreamEncrypter) Close

func (e *StreamEncrypter) Close() error

Close implements io.Closer interface

func (*StreamEncrypter) Write

func (e *StreamEncrypter) Write(p []byte) (n int, err error)

Write implements io.Writer interface

type WriteError

type WriteError struct {
	Err error // The underlying error that caused the failure
}

WriteError represents an error when writing encrypted data fails. This error occurs when writing encrypted data to the underlying writer fails. The error includes the underlying error for detailed debugging.

func (WriteError) Error

func (e WriteError) Error() string

Error returns a formatted error message describing the write failure. The message includes the underlying error for debugging.

Source Files

  • errors.go
  • rc4.go

Jump to

Keyboard shortcuts

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