Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 ext
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 benchmark
Octocat-spinner-32 fast_xor.gemspec
Octocat-spinner-32 fast_xor.kdev4
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”?

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

Something went wrong with that request. Please try again.