I recommend that you use the xorcist gem instead, as it has more features and support.
fast_xor
is a simple extension which provides fast in-place String XOR functions, suitable for cryptography.
require 'xor' # two-argument version a, b = 'a string', 'another string' a.xor!(b) a == "\000N\034\000\032\f\034G" # three-argument version a, b, c = 'a string', 'another string', 'yet another string' a.xor!(b, c) a == "y+h {bs3"
Over 5,000x faster than pure Ruby, on my machine (your mileage my vary):
$ ./benchmark user system total real Ruby : 4.530000 0.000000 4.530000 ( 4.535203) C (x1000): 0.780000 0.000000 0.780000 ( 0.781100)
- Author
-
Steve Sloan ([email protected])
- Website
- Copyright
-
Copyright © 2009-2013 Steve Sloan
- License
-
MIT