CodeMonkeySteve / fast_xor
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
566e226
fast_xor /
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Sun Jun 28 00:02:15 -0700 2009 | |
| |
README.rdoc | Mon Oct 26 19:31:38 -0700 2009 | |
| |
Rakefile | Mon Oct 26 19:31:38 -0700 2009 | |
| |
VERSION | Mon Oct 26 19:31:38 -0700 2009 | |
| |
ext/ | Sun Jun 28 00:02:15 -0700 2009 | |
| |
fast_xor.kdevelop | Mon Oct 26 19:32:05 -0700 2009 | |
| |
rake/ | Sun Jun 28 00:02:15 -0700 2009 | |
| |
test/ | Sun Jun 28 00:02:15 -0700 2009 |
README.rdoc
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"?
On my computer, about 1,000x faster than pure Ruby (your mileage my vary):
$ ruby test/benchmark.rb
user system total real
Ruby: 2.070000 0.930000 3.000000 ( 3.004088)
C : 0.010000 0.000000 0.010000 ( 0.003045)
| Author: | Steve Sloan (steve@finagle.org) |
| Website: | github.com/CodeMonkeySteve/fast_xor |
| Copyright: | Copyright © 2009 Steve Sloan |
| License: | MIT |
