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”?¶ ↑
Almost 50x faster than pure Ruby, on my machine (your mileage my vary):
$ ./benchmark user system total real Ruby : 6.100000 0.010000 6.110000 ( 6.307756) C (x1000): 0.140000 0.000000 0.140000 ( 0.144665)
- Author
-
Steve Sloan (steve@finagle.org)
- Website
- Copyright
-
Copyright © 2009-2013 Steve Sloan
- License
-
MIT