Standard library / crypto/rc4
crypto/rc4.Cipher
Broken legacy stream cipher. Its state advances on each XORKeyStream call; do not reuse keystream or use for new security. Public fixed key for an isolated test vector only; do not use it to protect real data. Expected stdout: 'bbf316e8d940af0ad3\n'.
Formal Syntax & Structure
go syntaxgo
type Cipher struct {}Working Example
Example Snippetgo
package main
import ( "crypto/rc4" "fmt")
func main() { // Historical interoperability demonstration only. Never deploy this cipher/mode. var c *rc4.Cipher = must(rc4.NewCipher([]byte("Key"))) dst := make([]byte, 9) c.XORKeyStream(dst, []byte("Plaintext")) fmt.Printf("%x\n", dst)}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) }}