Standard library / crypto/des
crypto/des.NewCipher()
Obsolete cipher; never use for new security systems. Accepts an 8-byte key, with only 56 effective key bits. Public fixed key for an isolated test vector only; do not use it to protect real data. Expected stdout: '8\n'.
Formal Syntax & Structure
go syntaxgo
func NewCipher(key []byte) (cipher.Block, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | []byte | Key bytes of a supported length. |
Return Value
(cipher.Block, error)
Cipher instance, or an error for an invalid key length.
Working Example
Example Snippetgo
package main
import ( "crypto/des" "fmt")
func main() { // Historical interoperability demonstration only. Never deploy this cipher/mode. b := must(des.NewCipher(make([]byte, 8))) fmt.Println(b.BlockSize())}func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}