Skip to content

Instantly share code, notes, and snippets.

@carlosjhr64
Created September 29, 2011 18:25
Show Gist options
  • Save carlosjhr64/1251509 to your computer and use it in GitHub Desktop.
Save carlosjhr64/1251509 to your computer and use it in GitHub Desktop.
xor strings onepass secrets
def onepass( target, *secrets )
output = target
secrets.select{|sec| !sec.nil?}.each do |secret|
output = output.bytes.inject(''){|string,byte| string + (byte^(secret[string.length] || 0.chr).ord).chr }
end
output
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment