Documentation
¶
Overview ¶
Package des implements DES encryption and decryption with streaming support. It provides DES encryption and decryption operations using the standard DES algorithm with support for 64-bit keys.
Index ¶
- func NewStreamDecrypter(r io.Reader, c *cipher.DesCipher) io.Reader
- func NewStreamEncrypter(w io.Writer, c *cipher.DesCipher) io.WriteCloser
- type BufferError
- type DecryptError
- type EncryptError
- type KeySizeError
- type ReadError
- type StdDecrypter
- type StdEncrypter
- type StreamDecrypter
- type StreamEncrypter
- type UnsupportedBlockModeError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStreamDecrypter ¶
NewStreamDecrypter creates a new DES stream decrypter with the specified reader and cipher. Validates the key length and cipher mode, then initializes the decrypter for DES streaming decryption operations. The key must be exactly 8 bytes for DES decryption. Only CBC, CTR, ECB, CFB, and OFB modes are supported.
func NewStreamEncrypter ¶
NewStreamEncrypter creates a new DES stream encrypter with the specified writer and cipher. Validates the key length and cipher mode, then initializes the encrypter for DES streaming encryption operations. The key must be exactly 8 bytes for DES encryption. Only CBC, CTR, ECB, CFB, and OFB modes are supported.
Types ¶
type BufferError ¶
type BufferError struct {
// contains filtered or unexported fields
}
BufferError represents an error when the buffer size is too small. This error occurs when the provided buffer is too small to hold the decrypted data. The error includes both buffer size and data size for detailed debugging.
func (BufferError) Error ¶
func (e BufferError) Error() string
Error returns a formatted error message describing the buffer size issue. The message includes both buffer size and data size for debugging.
type DecryptError ¶
type DecryptError struct {
Err error // The underlying error that caused the failure
}
DecryptError represents an error when DES decryption operation fails. This error occurs when the decryption process fails due to various reasons. The error includes the underlying error for detailed debugging.
func (DecryptError) Error ¶
func (e DecryptError) Error() string
Error returns a formatted error message describing the decryption failure. The message includes the underlying error for debugging.
type EncryptError ¶
type EncryptError struct {
Err error
}
EncryptError represents an error when DES encryption operation fails. This error occurs when the encryption process fails due to various reasons.
func (EncryptError) Error ¶
func (e EncryptError) Error() string
type KeySizeError ¶
type KeySizeError int
KeySizeError represents an error when the DES key size is invalid. DES keys must be exactly 8 bytes (64 bits). This error occurs when the provided key does not meet this size requirement.
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 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.
type StdDecrypter ¶
type StdDecrypter struct {
Error error // Error field for storing decryption errors
// contains filtered or unexported fields
}
StdDecrypter represents a DES decrypter for standard decryption operations. It implements DES decryption using the standard DES algorithm with support for 64-bit keys and various cipher modes.
func NewStdDecrypter ¶
func NewStdDecrypter(c *cipher.DesCipher) *StdDecrypter
NewStdDecrypter creates a new DES decrypter with the specified cipher. Validates the key length and cipher mode, then initializes the decrypter for DES decryption operations. The key must be exactly 8 bytes for DES decryption. Only CBC, CTR, ECB, CFB, and OFB modes are supported.
func (*StdDecrypter) Decrypt ¶
func (d *StdDecrypter) Decrypt(src []byte) (dst []byte, err error)
Decrypt decrypts the given byte slice using DES decryption. Creates a DES cipher block and uses the configured cipher interface to perform the decryption operation with proper error handling. Returns empty data when input is empty.
type StdEncrypter ¶
type StdEncrypter struct {
Error error // Error field for storing encryption errors
// contains filtered or unexported fields
}
StdEncrypter represents a DES encrypter for standard encryption operations. It implements DES encryption using the standard DES algorithm with support for 64-bit keys and various cipher modes.
func NewStdEncrypter ¶
func NewStdEncrypter(c *cipher.DesCipher) *StdEncrypter
NewStdEncrypter creates a new DES encrypter with the specified cipher. Validates the key length and cipher mode, then initializes the encrypter for DES encryption operations. The key must be exactly 8 bytes for DES encryption. Only CBC, CTR, ECB, CFB, and OFB modes are supported.
func (*StdEncrypter) Encrypt ¶
func (e *StdEncrypter) Encrypt(src []byte) (dst []byte, err error)
Encrypt encrypts the given byte slice using DES encryption. Creates a DES cipher block and uses the configured cipher interface to perform the encryption operation with proper error handling. Returns empty data when input is empty.
type StreamDecrypter ¶
type StreamDecrypter struct {
Error error // Error field for storing decryption errors
// contains filtered or unexported fields
}
StreamDecrypter represents a DES decrypter for streaming decryption operations. It implements DES decryption using the standard DES algorithm with support for 64-bit keys and various cipher modes, providing streaming capabilities with proper state management.
func (*StreamDecrypter) Read ¶
func (d *StreamDecrypter) Read(p []byte) (n int, err error)
Read implements the io.Reader interface for streaming DES decryption. On the first call, reads all encrypted data from the underlying reader and decrypts it. Subsequent calls return chunks of the decrypted data to maintain streaming interface.
type StreamEncrypter ¶
type StreamEncrypter struct {
Error error // Error field for storing encryption errors
// contains filtered or unexported fields
}
StreamEncrypter represents a DES encrypter for streaming encryption operations. It implements DES encryption using the standard DES algorithm with support for 64-bit keys and various cipher modes, providing streaming capabilities with true streaming support.
func (*StreamEncrypter) Close ¶
func (e *StreamEncrypter) Close() error
Close implements the io.Closer interface for the DES stream encrypter. Closes the underlying writer if it implements io.Closer. Note: All data is processed in Write method for compatibility with cipher interface.
func (*StreamEncrypter) Write ¶
func (e *StreamEncrypter) Write(p []byte) (n int, err error)
Write implements the io.Writer interface for streaming DES encryption. Provides improved performance through cipher block reuse while maintaining compatibility. Accumulates data and processes it using the cipher interface for consistency.
type UnsupportedBlockModeError ¶ added in v1.1.7
type UnsupportedBlockModeError struct {
Mode string // The unsupported mode name
}
UnsupportedBlockModeError represents an error when an unsupported block mode is used. This error occurs when trying to use cipher modes that are not supported by DES, such as GCM mode which requires 128-bit block size while DES only has 64-bit block size.
func (UnsupportedBlockModeError) Error ¶ added in v1.1.7
func (e UnsupportedBlockModeError) Error() string
Error returns a formatted error message describing the unsupported mode. The message includes the mode name and explains why it's not supported.
Source Files
¶
- des.go
- errors.go