Fixed XOR

Write a function that takes two equal-length buffers and produces their XOR combination.

See http://cryptopals.com/sets/1/challenges/2 for the problem description.


In [ ]:
a = "1c0111001f010100061a024b53535009181c"
b = "686974207468652062756c6c277320657965";

In [ ]:
ahex = hex2bytes(a)
bhex = hex2bytes(b);

In [ ]:
c = ahex $ bhex;

In [ ]:
base64encode(c)

In [ ]:
bytes2hex(c)

In [ ]:
length(a)

In [ ]:
function fxor(a::String, b::String)
    if length(a) == length(b)
        return bytes2hex(hex2bytes(a) $ hex2bytes(b))
    end
end;

In [ ]:
fxor(a, b)