[Q] string to int hash function for small range

From: "V S P" <toreason(at)fastmail(dot)fm>
To: pgsql-general(at)postgresql(dot)org
Subject: [Q] string to int hash function for small range
Date: 2009-03-08 02:33:33
Message-ID: 1236479613.5431.1304211299@webmail.messagingengine.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I would like to have a function
given a user id varchar(64) to get a hash number between 0 and 255.

I first tried md5 but the number it returns is very big and cannot
be converted to an INT

there is likely a way to simply add ascii values of the userId together
to get a small integer, but wanted to know if there are any other
'built-in' ways

this is to get the database id based on user id.

thanks in advance,
Vlad
--
V S P
toreason(at)fastmail(dot)fm

--
http://www.fastmail.fm - One of many happy users:
http://www.fastmail.fm/docs/quotes.html

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2009-03-08 03:23:25 Re: [Q] string to int hash function for small range
Previous Message John R Pierce 2009-03-08 01:08:46 Re: Enable user access from remote host