fork(2) download
  1. s1 = "1c0111001f010100061a024b53535009181c"
  2. s2 = "686974207468652062756c6c277320657965"
  3. s3 = "746865206b696420646f6e277420706c6179"
  4.  
  5. def xor_strings(a,b)
  6. return nil unless a.size == b.size
  7. fst = a.to_i(16)
  8. snd = b.to_i(16)
  9. res = fst ^ snd
  10. res.to_s(16)
  11. end
  12.  
  13. # test
  14. puts s3 == xor_strings(s1, s2)
Success #stdin #stdout 0.02s 7408KB
stdin
Standard input is empty
stdout
true