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

Function Encrypt

cipher/xor/xor.go:14–20  ·  view source on GitHub ↗

Encrypt encrypts with Xor encryption after converting each character to byte The returned value might not be readable because there is no guarantee which is within the ASCII range If using other type such as string, []int, or some other types, add the statements for converting the type to []byte.

(key byte, plaintext []byte)

Source from the content-addressed store, hash-verified

12// If using other type such as string, []int, or some other types,
13// add the statements for converting the type to []byte.
14func Encrypt(key byte, plaintext []byte) []byte {
15 cipherText := []byte{}
16 for _, ch := range plaintext {
17 cipherText = append(cipherText, key^ch)
18 }
19 return cipherText
20}
21
22// Decrypt decrypts with Xor encryption
23func Decrypt(key byte, cipherText []byte) []byte {

Callers 3

ExampleFunction · 0.70
TestXorCipherEncryptFunction · 0.70
FuzzXORFunction · 0.70

Calls

no outgoing calls

Tested by 3

ExampleFunction · 0.56
TestXorCipherEncryptFunction · 0.56
FuzzXORFunction · 0.56