Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The most common codes passed in URLs are hashes. There are different algorithms, most people use md5 but there are more secure ones. You can make your hash and then if you want to, lets say, limit access to a page depending on the hash being correct, you can check the value.</p> <p>url.com?x=5273909c02b8ce7ae42a4e21542b3326</p> <pre><code>if( $_GET['x'] == md5('hashcode') ) { // it matches }else{ // it doesn't } </code></pre> <p>There are other hasing algos, <a href="http://php.net/manual/en/ref.hash.php" rel="nofollow">here's some docs.</a> </p> <p>You can get these from the URL when used as part of the path via the .htaccess file. </p> <p>The specific algo used for those specific sites may be custom, but there are many preset functions in PHP that will let you mimic this.</p> <p>To generate a shorter one you could take the first several desired characters with the substr() function and use a database to make sure there are no collisions. When a new code is created, truncate it to the length desired and query the database to see if it has been used, insert if not.</p> <p>Or you could write your own and use the same process with the database to make sure there are no collisions.</p> <p>If you're going to have a lot of hashes, you might want to take some time making a good random string generator that incorporates all letters and numbers, the shorter your hash the greater the chance of collisions and the smaller the pool of possible combinations. Increasing the possible characters from 15^(characters used) with md5 to 36^(characters used) will <strong><em>greatly</em></strong> increase your pool of possible combinations.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload