Skip to content

Instantly share code, notes, and snippets.

@michael-lins
Forked from roadhouse/xorencrypt.rb
Created November 11, 2024 17:45
Show Gist options
  • Save michael-lins/8615d091c3a0b68643adb37a5b6a5d46 to your computer and use it in GitHub Desktop.
Save michael-lins/8615d091c3a0b68643adb37a5b6a5d46 to your computer and use it in GitHub Desktop.
def xor_encrypt(string, key)
string.bytes.map.with_index { |byte, index| (byte ^ key.bytes[index % key.length]).chr }.join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment