Documentation ¶
Overview ¶
Package ecb implements block cipher mode of encryption ECB (Electronic Code Book) functions. This is implemented for legacy purposes only and should not be used for any new encryption needs. Use CBC (Cipher Block Chaining) instead.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewECBDecrypter ¶
NewECBDecrypter returns a BlockMode which decrypts in electronic codebook (ECB) mode, using the given Block.
Example ¶
key := []byte("SomeBlowfishKey") ciphertext, err := hex.DecodeString("66E6E737F23E570ACA5710BA3C0E321A") if err != nil { panic(err.Error()) } block, err := blowfish.NewCipher(key) if err != nil { panic(err.Error()) } mode := NewECBDecrypter(block) plaintext := make([]byte, len(ciphertext)) mode.CryptBlocks(plaintext, ciphertext) fmt.Printf("%s\n", string(plaintext))
Output: exampleplaintext
Example (Second) ¶
key := []byte("AES256Key-32Characters1234567890") ciphertext, err := hex.DecodeString("717FADE7B97198A8C2F67766FBAC7B07") if err != nil { panic(err.Error()) } block, err := aes.NewCipher(key) if err != nil { panic(err.Error()) } mode := NewECBDecrypter(block) plaintext := make([]byte, len(ciphertext)) mode.CryptBlocks(plaintext, ciphertext) fmt.Printf("%s\n", string(plaintext))
Output: exampleplaintext
func NewECBEncrypter ¶
NewECBEncrypter returns a BlockMode which encrypts in elecronic codebook (ECB) mode, using the given Block (Cipher).
Example ¶
key := []byte("SomeBlowfishKey") plaintext := []byte("exampleplaintext") block, err := blowfish.NewCipher(key) if err != nil { panic(err.Error()) } mode := NewECBEncrypter(block) ciphertext := make([]byte, len(plaintext)) mode.CryptBlocks(ciphertext, plaintext) fmt.Printf("%X\n", ciphertext)
Output: 66E6E737F23E570ACA5710BA3C0E321A
Example (Second) ¶
key := []byte("AES256Key-32Characters1234567890") plaintext := []byte("exampleplaintext") block, err := aes.NewCipher(key) if err != nil { panic(err.Error()) } mode := NewECBEncrypter(block) ciphertext := make([]byte, len(plaintext)) mode.CryptBlocks(ciphertext, plaintext) fmt.Printf("%X\n", ciphertext)
Output: 717FADE7B97198A8C2F67766FBAC7B07
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.