Skip to content

Instantly share code, notes, and snippets.

@melkael
Created February 1, 2019 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melkael/1cd79b38a1d677883965b146a33067f5 to your computer and use it in GitHub Desktop.
Save melkael/1cd79b38a1d677883965b146a33067f5 to your computer and use it in GitHub Desktop.
func repeatingXorMakeKey(key string, length int) string {
ret := strings.Repeat(key, length/len(key)+1)
return ret[0:length]
}
func repeatingKeyXor(clear string, key string) string {
entryTab := strings.Split(clear, "\n")
output := ""
for i := 0; i < len(entryTab); i++ {
repeatedKey := repeatingXorMakeKey(key, len(entryTab[i]))
hexkey := fmt.Sprintf("%x", repeatedKey)
hexclear := fmt.Sprintf("%x", entryTab[i])
output += xor_equal_len(hexkey, hexclear)
output += "\n"
}
return output
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment