Facebook Twitter Reset

This Tutorial Has Been Viewed 1,276 Times.

MD5 Function and Unique ID in php

uniqid () function, This function has two parameters we can set. The first is the prefix. This is what will be appended to the beginning of each ID. The second is more_entropy. If this is false or not specified it will return 13 characters, if it is true then 23 characters will be returned.Uniqid (prefix, more_entropy)Sample Code Very Simple To Use

<?php 

echo ‘creates a unique id with the about prefix<br>’;

$a = uniqid(about);

echo $a;

echo “<hr>”;

echo ‘creates a longer unique id with the about prefix<br>’;

$b = uniqid (about, true);

echo $b;

echo “<hr>”;

echo ‘creates a unique ID with a random number as a prefix – more secure than a static prefix<br>’;

$c = uniqid (rand (),true);

echo $c;

echo “<hr>”;

echo ‘this md5 encrypts the username from above, so its ready to be stored in your database<br>’;

$md5 = md5($c);

echo $md5;

?>

 If you want a unique id then use uniqidThe id’s generated are only unique they are not completely random.If you want completly random id’s then you will need to make your own function, as an md5 or sha1 will not help. As these will provide you with a fixed length string. You could chop an md5 string at a random position, but then you would need to check that this string is unique and not just random 

VN:F [1.9.13_1145]
Rating: 9.0/10 (1 vote cast)
VN:F [1.9.13_1145]
Rating: -1 (from 1 vote)
MD5 Function and Unique ID in php, 9.0 out of 10 based on 1 rating

Incoming search terms:




You will also be interested in ,

No comments yet.

Leave a Comment

Spam protection by WP Captcha-Free

Affordable Seo PackagesSeo BlogEdu Backlinks
More in JavaScripts, scripts (85 of 143 articles)