Re: [Q] string to int hash function for small range

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: V S P <toreason(at)fastmail(dot)fm>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [Q] string to int hash function for small range
Date: 2009-03-08 04:17:19
Message-ID: dcc563d10903072017m169cc932n6e24614764484cab@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Mar 7, 2009 at 7:33 PM, V S P <toreason(at)fastmail(dot)fm> wrote:
> 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.

In psql type this:

\df *hash*

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2009-03-08 04:26:35 Re: [Q] string to int hash function for small range
Previous Message Martin Gainty 2009-03-08 03:25:23 Re: [Q] string to int hash function for small range