MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / Example

Function Example

cipher/xor/xor_test.go:10–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8)
9
10func Example() {
11 const (
12 seed = "Hello World"
13 key = 97
14 )
15
16 encrypted := Encrypt(byte(key), []byte(seed))
17 fmt.Printf("Encrypt=> key: %d, seed: %s, encryptedText: %v\n", key, seed, encrypted)
18
19 decrypted := Decrypt(byte(key), encrypted)
20 fmt.Printf("Decrypt=> key: %d, encryptedText: %v, DecryptedText: %s\n", key, encrypted, string(decrypted))
21
22 // Output:
23 // Encrypt=> key: 97, seed: Hello World, encryptedText: [41 4 13 13 14 65 54 14 19 13 5]
24 // Decrypt=> key: 97, encryptedText: [41 4 13 13 14 65 54 14 19 13 5], DecryptedText: Hello World
25}
26
27var xorTestData = []struct {
28 description string

Callers

nothing calls this directly

Calls 2

EncryptFunction · 0.70
DecryptFunction · 0.70

Tested by

no test coverage detected