This time for everyone to bring PHP one-way hash encryption function implementation, PHP one-way hash encryption function to realize the attention of what, the following is the actual case, together to see.
This paper describes the one-way hash encryption operation implemented by PHP. Share to everyone for your reference, as follows:
1. Encrypting files
<?php//sha1_en.phpheader ("Content-type:text/html;charset=utf-8"); $str = "I am Zhang San, can I have personal data"; $salt = "123456";// I am the only constant SALT$SHA1=SHA1 ($str. $salt);//or $SHA1=MD5 ($str. $salt); Echo $str; echo "<br/>" Echo $sha 1;echo "<br/ > "echo" http://localhost//sha1_de.php?str= $str &sha1= $sha 1 ";? >
2. Decrypting a file
<?php//sha1_de.phpheader ("Content-type:text/html;charset=utf-8"); $str =$_get["str"]; $sha 1=$_get["SHA1"];$ salt= "123456";//I am the only constant SALT$VERIFY=SHA1 ($str. $salt);//or $VERIFY=MD5 ($str. $salt); Echo $verify; if ($verify = = $sha 1) { echo "You are Zhang San, give you Information";} else{ echo "You are counterfeit products"; echo "Your IP". $_server[' REMOTE_ADDR ']. " have been recorded ";}?" >
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
Summarize some MySQL traps
How to operate the table in bootstrap
Use Angularjs to get passwords on the front-end interface