Skip to content

Instantly share code, notes, and snippets.

@d0ppler
Created April 21, 2015 06:16
Show Gist options
  • Save d0ppler/df0aad2bc78ac074996f to your computer and use it in GitHub Desktop.
Save d0ppler/df0aad2bc78ac074996f to your computer and use it in GitHub Desktop.
##
# should produce "746865206b696420646f6e277420706c6179"
# http://cryptopals.com/sets/1/challenges/2/
key = "1c0111001f010100061a024b53535009181c"
msg = "686974207468652062756c6c277320657965"
xor = key.unpack('C*').zip(msg.unpack('C*')).map{ |a,b| a ^ b }.pack('C*')
to_hex = xor.each_byte.map { |b| b.to_s(16) }.join
p to_hex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment