Example of one-way hash encryption implemented by PHP and example of encryption implemented by php
This example describes one-way hash encryption implemented by PHP. We will share this with you for your reference. The details are as follows:
1. Encrypted File
<? Php // shastmen.phpheader ("content-type: text/html; charset = UTF-8"); $ str = "I am Zhang San. Can you give me personal data "; $ salt = "123456"; // I am the only constant salt $ sha1 = sha1 ($ str. $ salt); // or $ sha1 = md5 ($ str. $ salt); echo $ str; echo "<br/>"; echo $ sha1; echo "<br/>"; echo "http: // localhost // shamo-de.php? Str = $ str & sha1 = $ sha1 ";?>
2. decrypt the file
<? Php // shamo-de.phpheader ("content-type: text/html; charset = UTF-8"); $ str =$ _ GET ["str"]; $ sha1 = $ _ GET ["sha1"]; $ salt = "123456"; // I am the only constant salt $ verify = sha1 ($ str. $ salt); // or $ verify = md5 ($ str. $ salt); echo $ verify; if ($ verify = $ sha1) {echo "you are Michael Zhang, give you information ";} else {echo "you are a fake and shoddy product"; echo "your ip address ". $ _ SERVER ['remote _ ADDR ']. "already recorded" ;}?>
PS: if you are interested in encryption and decryption, refer to the online tools on this site:
Online text encryption and decryption tools (including AES, DES, and RC4 ):
Http://tools.jb51.net/password/txt_encode
MD5 online encryption tool:
Http://tools.jb51.net/password/CreateMD5Password
Online hash/hash algorithm encryption tool:
Http://tools.jb51.net/password/hash_encrypt
Online MD5/hash/SHA-1/SHA-2/SHA-256/SHA-512/SHA-3/RIPEMD-160 encryption tools:
Http://tools.jb51.net/password/hash_md5_sha
Online sha1/shaloud/sha256/sha384/sha512 encryption tool:
Http://tools.jb51.net/password/sha_encode