Sun, 25 Jun 06

Generating a MicroId with Ruby

Very naive Ruby method to create a MicroId for a given email and url.

require 'digest/sha1'

def micro_id(email, url)
  email_digest = Digest::SHA1.new(email).to_s
  url_digest = Digest::SHA1.new(url).to_s
  Digest::SHA1.new(email_digest + url_digest).to_s
end

Note that there is no validation of the MicroId in this code at all.