old father arpanet shows you how rudimentary xor encryption works
Go to file
kayos@tcp.direct a905b451e6 FuckholeXORs 2022-01-11 23:53:57 -08:00
README.md FuckholeXORs 2022-01-11 23:53:57 -08:00
fuckholexors.go FuckholeXORs 2022-01-11 23:53:57 -08:00

fuckholexors.go

And educational example of a simple XOR pad function I made to help someone solve a challenge and learn a bit about computers.

Meat and Potatoes

package main

var secretstring = []byte("fuckhole")
var secretkey = []byte("jones")

func xorpad(input []byte, key []byte) []byte {
	var keyindex = 0
	var encoded = make([]byte, len(secretstring))
	for index, character := range input {
		if keyindex == len(key) {
			keyindex = 0
		}
		encoded[index] = character ^ key[keyindex]
		keyindex++
	}
	return encoded
}

Verbose Output:

secret string: fuckhole
`->in byte form:[102 117 99 107 104 111 108 101]
-----
secret key: jones
`->in byte form:[106 111 110 101 115]

-------------------------------------

(index) [in XOR key]   -> byte
 s   k

[0] [0]  102  ^  j(106) -> 12
[1] [1]  117  ^  o(111) -> 26
[2] [2]   99  ^  n(110) -> 13
[3] [3]  107  ^  e(101) -> 14
[4] [4]  104  ^  s(115) -> 27
[5] [0]  111  ^  j(106) -> 5
[6] [1]  108  ^  o(111) -> 3
[7] [2]  101  ^  n(110) -> 11

-------------------------------------

encoded xor result: [12 26 13 14 27 5 3 11]

-------------------------------------

(index) [in XOR key]   -> byte
 s   k

[0] [0]  12  ^  j(106) -> 102
[1] [1]  26  ^  o(111) -> 117
[2] [2]  13  ^  n(110) -> 99
[3] [3]  14  ^  e(101) -> 107
[4] [4]  27  ^  s(115) -> 104
[5] [0]   5  ^  j(106) -> 111
[6] [1]   3  ^  o(111) -> 108
[7] [2]  11  ^  n(110) -> 101

-------------------------------------

decoded xor result: fuckhole