Thursday, April 06, 2006

SHA-256 digest using Ruby

just too easy...

require 'digest/sha2'
result = Digest::SHA256.hexdigest "hoser"
(1..100000).each do |i| Digest::SHA256.hexdigest i.to_s end

Granted those are not complex strings, but ripping through 100,000 in a ~1second isn't bad (1.7mhz Pentium M, 1G RAM).

No comments: