PHP uses the crypt () function to encrypt the sample code

Source: Internet
Author: User
Tags crypt
The crypt () function returns a string that is encrypted using the DES, Blowfish, or MD5 algorithms.

On different operating systems, the function behaves differently, and some operating systems support more than one type of algorithm. At installation time, PHP checks what algorithms are available and what algorithms are used.

The specific algorithm relies on the format and length of the salt parameter. Salt makes encryption more secure by increasing the number of strings that are generated by specific strings that use a particular encryption method.

This article is mainly for the detailed introduction of PHP using the crypt () function to encrypt

One, the code

<?php  $str = ' Apply crypt () function for one-way encryption! ';     Declares the string variable $str  echo ' before encrypting the value of $str: '. $str;  $crypttostr = Crypt ($STR);      The value of the $STR encryption  Echo ' <p> encryption $str after the variable is: '. $crypttostr;  Output the encrypted variable?

Ii. Results of operation

Parameters do not have a salt, each encryption results in a different cipher.
The $STR value before encryption is: Apply the crypt () function for one-way encryption!
The value of $str after encryption is: $1$re4.gg4. $D. yd00xx0fffifp6krkgn0

Third, the Code

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 

Iv. Results of operation

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.