<?php /** * A Compatibility library with PHP 5.5's simplified password hashing API. * * @author Anthony Ferrara <ircmaxell@php.net> * @license http://www.opensource.org/licenses/mit-license.html MIT License * @copyright 2012 The Authors */ namespace { if (!defined('PASSWORD_BCRYPT')) { /** * PHPUnit Process isolation caches constants, but not function declarations. * So we need to check if the constants are defined separately from * the functions to enable supporting process isolation in userland * code. */ define('PASSWORD_BCRYPT', 1); define('PASSWORD_DEFAULT', PASSWORD_BCRYPT); define('PASSWORD_BCRYPT_DEFAULT_COST', 10); }
I believe that when many PHP developers first came into contact with PHP, the preferred encryption function for handling passwords might be MD5. This is what I did at the time:
$password = md5($_POST["password "]);
Does the above code sound familiar? However, the MD5 encryption method seems to be not very popular in the PHP world at present, because its encryption algorithm is a bit simple, and many password cracking sites store a lot of MD5 encrypted password strings, so here I strongly discourage using MD5 alone to encrypt user passwords.
SHA256 and SHA512
In fact, there is a SHA1 encryption method at the same time as the previous MD5, but the algorithm is relatively simple, so I will briefly mention it here. The SHA256 and SHA512 we are about to talk about here are encryption functions from the SHA2 family. You may have guessed it by looking at the names. These two encryption methods generate hash strings of 256 and 512 bit length respectively.
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
16Jun2023
Use of PHP encryption and decryption function library As network security issues become increasingly prominent, encryption has become an indispensable part of modern network technology. In PHP, the encryption and decryption function library provides many encryption and decryption functions, which can be used to process sensitive information and ensure data security. This article will introduce the use of PHP encryption and decryption function library. 1. Commonly used encryption and decryption functions md5 encryption: md5 encryption is an irreversible encryption method that is often used to store passwords and verify the integrity of files. The usage is very simple, for example: $messag
05Jul2017
PHP encryption extension libraries include Mcrypt and Mhash. Among them, the Mcrypt extension library can implement encryption and decryption functions. Today we are talking about the functions and examples of Mcrypt.
15Jul2016
Share installation and application tips of PHP encryption extension library Mcrypt. Among them, the Mcrypt extension library can implement encryption and decryption functions, that is, it can not only encrypt plaintext but also restore ciphertext. 1. The PHP encryption extension library Mcrypt is not installed during the standard PHP installation process.
13Jul2016
PHP encryption and decryption class example analysis, encryption and decryption example analysis. PHP encryption and decryption class example analysis, encryption and decryption example analysis This article describes the PHP encryption and decryption class. Share it with everyone for your reference. The specific analysis is as follows: This code supports array addition
12Jul2016
Encryption and decryption processing class implemented by PHP, encryption and decryption implemented by PHP. Encryption and decryption processing class implemented by PHP, encryption and decryption implemented by PHP This article describes the encryption and decryption processing class implemented by PHP. Share it with everyone for your reference, the details are as follows: php /*==========
13Jul2016
Analysis of PHP encryption and decryption class examples. Example Analysis of PHP Encryption and Decryption Class This article mainly introduces the PHP encryption and decryption class. The example analyzes the principles and related techniques of PHP encryption and decryption. It is of great practical value. Friends who need it can
Hot Tools
PHP string encryption and decryption class
PHP string encryption and decryption class
PHP symmetric encryption algorithm DES and AES classes
PHP symmetric encryption algorithm DES and AES classes
Powerful php encryption and decryption class
Powerful php encryption and decryption class