package twofish
import "golang.org/x/crypto/twofish"
Package twofish implements Bruce Schneier's Twofish encryption algorithm.
Deprecated: Twofish is a legacy cipher and should not be used for new applications. Also, this package does not and will not provide an optimized implementation. Instead, use AES (from crypto/aes, if necessary in an AEAD mode like crypto/cipher.NewGCM) or XChaCha20-Poly1305 (from golang.org/x/crypto/chacha20poly1305).
Index ¶
- Constants
- type Cipher
- func NewCipher(key []byte) (*Cipher, error)
- func (c *Cipher) BlockSize() int
- func (c *Cipher) Decrypt(dst, src []byte)
- func (c *Cipher) Encrypt(dst, src []byte)
- type KeySizeError
Constants ¶
const BlockSize = 16
BlockSize is the constant block size of Twofish.
Types ¶
type Cipher ¶
type Cipher struct {
// contains filtered or unexported fields
}
A Cipher is an instance of Twofish encryption using a particular key.
func NewCipher ¶
NewCipher creates and returns a Cipher. The key argument should be the Twofish key, 16, 24 or 32 bytes.
func (*Cipher) BlockSize ¶
BlockSize returns the Twofish block size, 16 bytes.
func (*Cipher) Decrypt ¶
Decrypt decrypts a 16-byte block from src to dst, which may overlap.
func (*Cipher) Encrypt ¶
Encrypt encrypts a 16-byte block from src to dst, which may overlap. Note that for amounts of data larger than a block, it is not safe to just call Encrypt on successive blocks; instead, use an encryption mode like CBC (see crypto/cipher/cbc.go).
type KeySizeError ¶
type KeySizeError int
func (KeySizeError) Error ¶
func (k KeySizeError) Error() string
Source Files ¶
twofish.go
- Version
- v0.34.0 (latest)
- Published
- Feb 22, 2025
- Platform
- linux/amd64
- Imports
- 2 packages
- Last checked
- 9 hours ago –
Tools for package owners.