Project

fast_xor

0.02
No commit activity in last 3 years
No release in over 3 years
Provides a C-optimized method for in-place XORing of two (or three) strings
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0

Runtime

 Project Readme

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