This option will reset the home page of this site. Restoring any closed widgets or categories.

Reset

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.5.7_846]
Rating: 0.0/10 (0 votes cast)
VN:F [1.5.7_846]
Rating: 0 (from 0 votes)

Related posts:

  1. Water mark images using PHP 5 and GD Library
  2. “Header already sent” in php error and other use of Header function in PHP

Leave a Reply

Comments (required)

Spam Protected