Implementation of PHP One-way hash encryption function

Source: Internet
Author: User
Tags sha1
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.