Skip to content

Instantly share code, notes, and snippets.

@mthelander
Created January 8, 2012 03:39
Show Gist options
  • Save mthelander/1577076 to your computer and use it in GitHub Desktop.
Save mthelander/1577076 to your computer and use it in GitHub Desktop.
string xor cipher
class String
def xor(key)
''.tap do |result|
self.size.times do |n|
result << (self[n].ord ^ key[n % key.size].ord).chr
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment