Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeySizeError ¶
type KeySizeError int
KeySizeError is returned when the provided key is not of the correct size.
func (KeySizeError) Error ¶
func (k KeySizeError) Error() string
Error implements the error interface. Parameters:
- k: The KeySizeError value representing the invalid key size
Returns:
- string: A formatted error message indicating the invalid key size
type RC4 ¶
type RC4 struct {
// Key is the key used to initialize the cipher.
Key []byte
// contains filtered or unexported fields
}
RC4 represents an RC4 cipher instance.
func NewRC4 ¶
NewRC4 creates and returns a new RC4 cipher. The key is empty, so the cipher is not initialized. Parameters:
- None
Returns:
- *RC4: A pointer to a new RC4 cipher instance
- error: An error if the cipher could not be created
func NewRC4WithKey ¶
NewRC4WithKey creates and returns a new RC4 cipher with the given key. The key must be between 1 and 256 bytes in length. Parameters:
- key: The byte slice containing the key for the RC4 cipher
Returns:
- *RC4: A pointer to a new RC4 cipher instance initialized with the key
- error: An error if the key size is invalid
func (*RC4) Reset ¶
func (c *RC4) Reset()
Reset zeros the key data and resets the cipher to its initial state. Parameters:
- c: The RC4 cipher instance to reset
Returns:
- None
func (*RC4) XORKeyStream ¶
XORKeyStream applies the RC4 cipher to the byte slice. It encrypts or decrypts the bytes in src and writes the result to dst. Src and dst may be the same slice but otherwise should not overlap. Parameters:
- dst: The destination byte slice where the result will be written
- src: The source byte slice containing the data to be encrypted/decrypted
Returns:
- None
Panics:
- If dst is smaller than src
- If src and dst overlap but are not identical slices