From: Peter Szinek Date: 2008-11-12T23:47:57+09:00 Subject: Re: Convert text string i.e 'Peter' into integer ID > Thanks for your help. No I need to turn the string which would usually > be a headline ('Man lands on the moon') into a unique number. The > purpose is to speed up my database queries when checking whether an > entry with the same headline already exists in the db. If you just want to check for duplicates, just store a SHA1 hash of the string: (AR example follows, obviously you can use any ORM or plain SQL): require "sha1"; headline = "Man lands on the moon" Article.create(:headline => headline, uniq_hash => SHA1.digest(headline)) ... later .... you want to decide whether new_headline already exists: Article.create( ... ) unless Article.find_by_uniq_hash(SHA1.digest(new_headline)) HTH, Peter