# package des
`import "crypto/des"`
des包实现了DES标准和TDEA算法,参见U.S. Federal Information Processing Standards Publication 46-3。
## Index
* [Constants](#pkg-constants)
* [type KeySizeError](#KeySizeError)
* [func (k KeySizeError) Error() string](#KeySizeError.Error)
* [func NewCipher(key []byte) (cipher.Block, error)](#NewCipher)
* [func NewTripleDESCipher(key []byte) (cipher.Block, error)](#NewTripleDESCipher)
## Constants
```
const BlockSize = 8
```
DES字节块的大小。
## type [KeySizeError](https://github.com/golang/go/blob/master/src/crypto/des/cipher.go#L15 "View Source")
```
type KeySizeError int
```
### func (KeySizeError) [Error](https://github.com/golang/go/blob/master/src/crypto/des/cipher.go#L17 "View Source")
```
func (k KeySizeError) Error() string
```
## func [NewCipher](https://github.com/golang/go/blob/master/src/crypto/des/cipher.go#L27 "View Source")
```
func NewCipher(key []byte) (cipher.Block, error)
```
创建并返回一个使用DES算法的cipher.Block接口。
## func [NewTripleDESCipher](https://github.com/golang/go/blob/master/src/crypto/des/cipher.go#L49 "View Source")
```
func NewTripleDESCipher(key []byte) (cipher.Block, error)
```
创建并返回一个使用TDEA算法的cipher.Block接口。
Example
```
// NewTripleDESCipher can also be used when EDE2 is required by
// duplicating the first 8 bytes of the 16-byte key.
ede2Key := []byte("example key 1234")
var tripleDESKey []byte
tripleDESKey = append(tripleDESKey, ede2Key[:16]...)
tripleDESKey = append(tripleDESKey, ede2Key[:8]...)
_, err := des.NewTripleDESCipher(tripleDESKey)
if err != nil {
panic(err)
}
// See crypto/cipher for how to use a cipher.Block for encryption and
// decryption.
```
- 库
- package achive
- package tar
- package zip
- package bufio
- package builtin
- package bytes
- package compress
- package bzip2
- package flate
- package gzip
- package lzw
- package zlib
- package container
- package heap
- package list
- package ring
- package crypto
- package aes
- package cipher
- package des
- package dsa
- package ecdsa
- package elliptic
- package hmac
- package md5
- package rand
- package rc4
- package rsa
- package sha1
- package sha256
- package sha512
- package subtle
- package tls
- package x509
- package pkix
- package database
- package sql
- package driver
- package encoding
- package ascii85
- package asn1
- package base32
- package base64
- package binary
- package csv
- package gob
- package hex
- package json
- package pem
- package xml
- package errors
- package expvar
- package flag
- package fmt
- package go
- package doc
- package format
- package parser
- package printer
- package hash
- package adler32
- package crc32
- package crc64
- package fnv
- package html
- package template
- package image
- package color
- package palette
- package draw
- package gif
- package jpeg
- package png
- package index
- package suffixarray
- package io
- package ioutil
- package log
- package syslog
- package math
- package big
- package cmplx
- package rand
- package mime
- package multipart
- package net
- package http
- package cgi
- package cookiejar
- package fcgi
- package httptest
- package httputil
- package pprof
- package mail
- package rpc
- package jsonrpc
- package smtp
- package textproto
- package url
- package os
- package exec
- package signal
- package user
- package path
- package filepath
- package reflect
- package regexp
- package runtime
- package cgo
- package debug
- package pprof
- package race
- package sort
- package strconv
- package strings
- package sync
- package atomic
- package text
- package scanner
- package tabwriter
- package template
- package time
- package unicode
- package utf16
- package utf8
- package unsafe