fork(131) download
  1. def sxor(s1,s2):
  2. # convert strings to a list of character pair tuples
  3. # go through each tuple, converting them to ASCII code (ord)
  4. # perform exclusive or on the ASCII code
  5. # then convert the result back to ASCII (chr)
  6. # merge the resulting array of characters as a string
  7. return ''.join(chr(ord(a) ^ ord(b)) for a,b in zip(s1,s2))
  9. print repr(sxor('Hello', 'world'))
Success #stdin #stdout 0.08s 8832KB
Standard input is empty