package set1 func XOREncryptText(plaintext string, key string) (cipher []byte) { cursor := 0 nextKeyChar := func() (char byte) { char = key[cursor] cursor++ if cursor >= len(key) { cursor = 0 } return } cipher = make([]byte, len(plaintext), len(plaintext)) for i := 0; i < len(plaintext); i++ { cipher[i] = plaintext[i] ^ nextKeyChar() } return } func ConvertToHex(bytes []byte) (hexBytes []byte) { for i := 0; i < len(bytes); i++ { hexBytes = append(hexBytes, HexRepresentations[bytes[i]>>4], HexRepresentations[0b00001111&bytes[i]]) } return }