Home  >  Article  >  Backend Development  >  Examples of md5 and uniqid functions in php

Examples of md5 and uniqid functions in php

WBOY
WBOYOriginal
2016-07-25 08:56:391345browse
This article introduces a few small examples of md5 and uniqid functions in PHP for reference by beginners.

1, md5 example

<?
$id = md5(uniqid(rand()));
echo "$id";
?>

2, use md5 function to encrypt text

<?php
   $val = "secret";
   echo "Pre-hash string: $val <br />";
   $hash_val = md5 ($val);
   echo "Hashed outcome: $hash_val";
?>

3, use uniqid function to generate id

<?
$id = uniqid("phpuser");
echo "$id";
?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn