version: 1.10

package des

import "crypto/des"

Overview

Package des implements the Data Encryption Standard (DES) and the Triple Data
Encryption Algorithm (TDEA) as defined in U.S. Federal Information Processing
Standards Publication 46-3.

DES is cryptographically broken and should not be used for secure applications.

Index

Examples

Package files

block.go cipher.go const.go

Constants

  1. const BlockSize = 8

The DES block size in bytes.

func NewCipher

  1. func NewCipher(key []byte) (cipher.Block, error)

NewCipher creates and returns a new cipher.Block.

func NewTripleDESCipher

  1. func NewTripleDESCipher(key []byte) (cipher.Block, error)

NewTripleDESCipher creates and returns a new cipher.Block.


Example:

  1. // NewTripleDESCipher can also be used when EDE2 is required by
  2. // duplicating the first 8 bytes of the 16-byte key.
  3. ede2Key := []byte("example key 1234")
  4. var tripleDESKey []byte
  5. tripleDESKey = append(tripleDESKey, ede2Key[:16]...)
  6. tripleDESKey = append(tripleDESKey, ede2Key[:8]...)
  7. _, err := des.NewTripleDESCipher(tripleDESKey)
  8. if err != nil {
  9. panic(err)
  10. }
  11. // See crypto/cipher for how to use a cipher.Block for encryption and
  12. // decryption.

type KeySizeError

  1. type KeySizeError int

func (KeySizeError) Error

  1. func (k KeySizeError) Error() string