|
Posted by Alvaro G. Vicario on 08/11/06 20:53
*** howachen@gmail.com escribió/wrote (11 Aug 2006 01:59:53 -0700):
> Nowadays, many site use encrypted resource ID, rather than plain
> numeric ID, such as the following:
>
>>> http://www.youtube.com/watch?v=p_YMigZmUuk
This is not encryption, it's just a random ID (or maybe a hash). The more
different chars you use, the shorter the string can be.
> "p_YMigZmUuk" will be mapped into a database unique ID (numeric, auto
> increment).
I'd just store it as string and unique key.
> What kind of encryption in PHP is the best in handling this job?
You can calculate hashes with md5(), crc32() or sha1(), but you must be
aware that hashes are one-way: you can't get the original string back.
For random strings, you can use uniqid() or you can write a custom function
using mt_rand().
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Navigation:
[Reply to this message]
|