/fast_xor

Fast String XOR operator

Primary LanguageRubyMIT LicenseMIT

THIS GEM IS DEPRECATED

I recommend that you use the xorcist gem instead, as it has more features and support.

String XOR Ruby Extension

fast_xor is a simple extension which provides fast in-place String XOR functions, suitable for cryptography.

How do you use it?

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"

How fast is “Fast”?

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 (steve@finagle.org)

Website

github.com/CodeMonkeySteve/fast_xor

Copyright

Copyright © 2009-2013 Steve Sloan

License

MIT