Converting a string to a number by using INT (no hash method)
d at davea.name
Tue Jan 22 17:40:57 CET 2013
On 01/22/2013 11:15 AM, Ferrous Cranus wrote:
> I just need a way to CONVERT a string(absolute path) to a 4-digit unique number with INT!!! That's all i want!! But i cannot make it work :(
> And the best part is that "that" number must be able to turn back into a path.
> This way i DON'T EVEN HAVE TO STORE THE ACTUAL HTML PAGE'S ABSOLUTE PATH!!!!
> 1. User requests a specific html page( .htaccess gives my script the absolute path for that .html page)
> 2. I turn the path into a 4-digitnumber
> 3. i store that number to the database. I DONT EVEN HAVE TO STORE THE PATH TO THE DATABASE ANYMORE!!! this is just great!
I had prepared a detailed response, showing what your choices are with
this new constraint. But I can see from this post here that there's no
point, so I've thrown it out.
Either you're trolling, or you have a very limited knowledge of
mathematics. This isn't a programming problem, it's a simple problem
of information theory.
Unless you constrain your users to very restrictive filenames, what you
ask here simply cannot be done.
Perpetual motion machine, anyone? Or a compression algorithm which can
be applied repeatedly to a chunk of data until it shrinks down to one
byte? No way to do it without cheating, and the literature is full of
examples of people cheating.
More information about the Python-list