Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Converting a number back to it's original string (that was hashed to generate that number)

by Nik
on Jan 23, 2013 at 13:44 UTC ( #1014905=note: print w/replies, xml ) Need Help??


in reply to Re: Converting a number back to it's original string (that was hashed to generate that number)
in thread Reaped: Converting a number back to it's original string (that was hashed to generate that number)

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^2: Converting a number back to it's original string (that was hashed to generate that number)

Replies are listed 'Best First'.
Re^3: Converting a number back to it's original string (that was hashed to generate that number)
by roboticus (Chancellor) on Jan 23, 2013 at 14:00 UTC

    Nik:

    What part of my post was unclear? If you're going to persist, then you, not us, are going to have to figure out the mapping, ensure the constraints on the string, and write the python code.

    I'll speak no more on the topic.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^3: Converting a number back to it's original string (that was hashed to generate that number)
by Anonymous Monk on Jan 23, 2013 at 20:06 UTC

    HOW to map both ways, in a one to one relation, (5-digit-integer <=> string) without losing any information?

    CREATE TABLE pin_to_url ( pin int PRIMARY KEY, url varchar(255) ); SELECT v.*, pu.url FROM visitors v JOIN pin_to_url pu ON pu.pin = v.pin ORDER BY whatever;

    Just store the filename alongside the pin into the table and it'll work pretty well.

    The only other way of mapping string to pin -- apart from the lookup table I've just typed out -- is enumerating over the possible filenames and hashing each in turn, comparing the result to the pin. There's no way around it with the constraints you stubbornly add.

    Oh, by the way, with 100 files and 10k available (random-ish) identification numbers, you might hit the birthday paradox. About 60% probable, I think. You don't want a hashing function -- you want an integer sequence. Databases provide those.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1014905]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2021-07-30 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?