shedokan Posted April 14, 2009 Share Posted April 14, 2009 Is there a way to convert a path like "path/to/file" to a unique number that can be decoded to reveal the path? thanks. Quote Link to comment https://forums.phpfreaks.com/topic/154084-convert-path-to-a-unique-number-that-is-unique-to-that-path/ Share on other sites More sharing options...
rhodesa Posted April 14, 2009 Share Posted April 14, 2009 numbers only? i guess you could convert each character to it's ASCII equivalent you can also look into base64_encode/decode Quote Link to comment https://forums.phpfreaks.com/topic/154084-convert-path-to-a-unique-number-that-is-unique-to-that-path/#findComment-809962 Share on other sites More sharing options...
rhodesa Posted April 14, 2009 Share Posted April 14, 2009 http://www.w3schools.com/PHP/func_string_bin2hex.asp Quote Link to comment https://forums.phpfreaks.com/topic/154084-convert-path-to-a-unique-number-that-is-unique-to-that-path/#findComment-809966 Share on other sites More sharing options...
shedokan Posted April 14, 2009 Author Share Posted April 14, 2009 thanks but I need a 12 characters length and only numbers. Quote Link to comment https://forums.phpfreaks.com/topic/154084-convert-path-to-a-unique-number-that-is-unique-to-that-path/#findComment-809978 Share on other sites More sharing options...
rhodesa Posted April 14, 2009 Share Posted April 14, 2009 you are limited to 12 numeric characters? that is pretty restrictive. the only option i can see possible is to record the path somewhere (a db table for instance) and give it a unique id. then you can look up the value by that unique id Quote Link to comment https://forums.phpfreaks.com/topic/154084-convert-path-to-a-unique-number-that-is-unique-to-that-path/#findComment-809994 Share on other sites More sharing options...
shedokan Posted April 14, 2009 Author Share Posted April 14, 2009 thanks everyone, but I guess rhodesa is right. I'm going to be using sessions. and somehow save them to a file or something. I will not be using a db. Quote Link to comment https://forums.phpfreaks.com/topic/154084-convert-path-to-a-unique-number-that-is-unique-to-that-path/#findComment-810055 Share on other sites More sharing options...
Daniel0 Posted April 14, 2009 Share Posted April 14, 2009 You could use MD5. Won't have a length of 12, but it'll be numeric. Quote Link to comment https://forums.phpfreaks.com/topic/154084-convert-path-to-a-unique-number-that-is-unique-to-that-path/#findComment-810058 Share on other sites More sharing options...
rhodesa Posted April 14, 2009 Share Posted April 14, 2009 MD5 uses 0-9 and a-f can you maybe elaborate more on what you are trying to accomplish exactly? maybe there are other options Quote Link to comment https://forums.phpfreaks.com/topic/154084-convert-path-to-a-unique-number-that-is-unique-to-that-path/#findComment-810068 Share on other sites More sharing options...
Daniel0 Posted April 14, 2009 Share Posted April 14, 2009 MD5 uses 0-9 and a-f Well, it's not a string though, it's a hexadecimal number which could easily be converted to base 10. Quote Link to comment https://forums.phpfreaks.com/topic/154084-convert-path-to-a-unique-number-that-is-unique-to-that-path/#findComment-810074 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.