Re: munge / obfuscate ?
| From: | Colin Guthrie | Date: | Fri, 28 Mar 2008 02:02:32 +0000 |
| Subject: | Re: munge / obfuscate ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-272195@lists.php.net to get a copy of this message | ||
Joey wrote:
> Hi All,
>
>
>
> I have written an app to allow a person to go online and see a picture we
> take of them. When we link to the picture I don't want it to be obvious
> that the URL is
>
> Domain.Com/Pix/123.jpg because the next person we take a picture of may be
> 123.jpg, so I am trying to munge/obfuscate the URL to make it less obvious.
Just give the files a name based on a "Universally Unique Identifier".
http://en.wikipedia.org/wiki/UUID
OK, you /could/ get a clash of names, but this is a) very unlikely and
b) simple to check for.
There is a PECL module for PHP to generate these:
http://pecl.php.net/package/uuid (new version just a
couple days ago
after a 4 year gap.... if that's not a sign I don't know what is!).
If you can't install the PECL module, but do have a MySQL server to hand
you can abuse it by doing:
mysql> SELECT UUID();
+--------------------------------------+
| UUID() |
+--------------------------------------+
| 14255808-4dbb-102b-a371-0015c5bd762d |
+--------------------------------------+
1 row in set (0.00 sec)
HTHs
Col