views:

56

answers:

3

We have an alpha numeric string (up to 32 characters) and we want to transform it to an integer (bigint). Now we're looking for an algorithm to do that. Collision isn't bad (therefor we use an bigint to prevent this a little bit), important thing is, that the calculated integers are constantly distributed over bigint range and the calculated integer is always the same for a given string.

A: 

Most programming languages come with a built-in construct or a standard library call to do this. Without knowing the language, I don't think anyone can help you.

tdammers
A standard library call to turn an alphanumeric string (such as "123qza5") into a bigint? I think the question is quite clear what's needed.
Chris
I actually read the question as "interpret a string as a number", not "calculate a numeric hash for a string".
tdammers
A: 

This page has a few. You'll need to port to 64bit, but that should be trivial. A C# port of SBDM hash is here. Another page of hash functions here

spender
I'll have a look at this
A: 

Yes, a "hash" should be the right description for my problem. I know, that there is CRC32, but it only provides an 32-bit int (in PHP) and this 32-bit integers are at least 10 characters long, so a huge range of integer number is unused!?

Mostly, we have a short string like "PX38IEK" or an 36 character UUID like "24868d36-a150-11df-8882-d8d385ffc39c", so the strings are arbitrary, yes.

It doesn't has to be reversible (so collisions aren't bad). It also doesn't matter what int a string is converted to, my only wish is, that the full bigint range is used as best as possible.