?
This document uses PHP Chinese website manual Release
import "crypto/des"
概述
索引
示例
des包實現(xiàn)了美國聯(lián)邦信息處理標準出版物(U.S. Federal Information Processing Standards Publication)46-3中定義的數(shù)據(jù)加密標準(DES)和三重數(shù)據(jù)加密算法(TDEA)。
DES 密碼破解,不應用于安全應用程序。
Constants
func NewCipher(key []byte) (cipher.Block, error)
func NewTripleDESCipher(key []byte) (cipher.Block, error)
type KeySizeError
func (k KeySizeError) Error() string
NewTripleDESCipher
block.go cipher.go const.go
DES塊大小以字節(jié)為單位。
const BlockSize = 8
func NewCipher(key []byte) (cipher.Block, error)
NewCipher 創(chuàng)建并返回一個新的 cipher.Block。
func NewTripleDESCipher(key []byte) (cipher.Block, error)
NewTripleDESCipher 創(chuàng)建并返回一個新的 cipher.Block。
package mainimport ("crypto/des")func main() {// 當需要EDE2時,NewTripleDESCipher也可以使用// 復制16字節(jié)密鑰的前8個字節(jié)。 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)}// 請參閱crypto/cipher 以了解如何使用密碼加密和加密// 解密。}
type KeySizeError int
func (k KeySizeError) Error() string