Hash id in url php
<p>Logged in user on my site can create documents, pretty much like on Google Docs. The document can be made public by the user, or private (defualt). The documents are stored in a database table like this:</p>

<pre><code>| id | title | content | public | owner |
| 1  | asd   | asd     | 1      |  1    |
| 2  | asd   | asd     | 0      |  1    |
| 3  | asd   | asd     | 0      |  2    |
</code></pre>

<p>If public equals 1, it is a public document that can  be viewed with a link from any user:
site.com/documents/id</p>

<p>The thing is, even though documents can be public, I don't want users to be able to just increment the url ID by 1 all the time to access all public documents:</p>

<ul>
<li>site.com/documents/1</li>
<li>site.com/documents/2</li>
<li>site.com/documents/3</li>
</ul>

<p>And so on...</p>

<p>So maybe I should hash the ID or something like that? Like so:</p>

<pre><code>&lt;?php echo 'site.com/documents/'.md5($id); ?&gt;
</code></pre>

<p>Problem is, I can't figure out which ID it is on server side since it is hashed...</p>

<p>What can I do about my problem?</p>
