crypto: Index | Files

package blowfish

import ""

Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.


Package Files

block.go cipher.go const.go


const BlockSize = 8

The Blowfish block size in bytes.

func ExpandKey Uses

func ExpandKey(key []byte, c *Cipher)

ExpandKey performs a key expansion on the given *Cipher. Specifically, it performs the Blowfish algorithm's key schedule which sets up the *Cipher's pi and substitution tables for calls to Encrypt. This is used, primarily, by the bcrypt package to reuse the Blowfish key schedule during its set up. It's unlikely that you need to use this directly.

type Cipher Uses

type Cipher struct {
    // contains filtered or unexported fields

A Cipher is an instance of Blowfish encryption using a particular key.

func NewCipher Uses

func NewCipher(key []byte) (*Cipher, error)

NewCipher creates and returns a Cipher. The key argument should be the Blowfish key, from 1 to 56 bytes.

func NewSaltedCipher Uses

func NewSaltedCipher(key, salt []byte) (*Cipher, error)

NewSaltedCipher creates a returns a Cipher that folds a salt into its key schedule. For most purposes, NewCipher, instead of NewSaltedCipher, is sufficient and desirable. For bcrypt compatibility, the key can be over 56 bytes.

func (*Cipher) BlockSize Uses

func (c *Cipher) BlockSize() int

BlockSize returns the Blowfish block size, 8 bytes. It is necessary to satisfy the Block interface in the package "crypto/cipher".

func (*Cipher) Decrypt Uses

func (c *Cipher) Decrypt(dst, src []byte)

Decrypt decrypts the 8-byte buffer src using the key k and stores the result in dst.

func (*Cipher) Encrypt Uses

func (c *Cipher) Encrypt(dst, src []byte)

Encrypt encrypts the 8-byte buffer src using the key k and stores the result in dst. 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 Uses

type KeySizeError int

func (KeySizeError) Error Uses

func (k KeySizeError) Error() string

Package blowfish imports 1 packages (graph) and is imported by 27 packages. Updated 2017-04-26. Refresh now. Tools for package owners.