<?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

10 Dec 2024
Encryption and Decryption in PHPEncrypting Sensitive DataPHP offers various encryption algorithms and methods to protect sensitive data stored in...

26 Nov 2024
RSA Encryption and Decryption without Padding in PHP 5.3Question:Is there a PHP 5.3 class that enables RSA encryption/decryption without padding?...

17 Nov 2024
Encrypting and Decrypting Files with MCryptThe Mcrypt library provides functions for encryption and decryption operations in PHP. Here's an...

15 Dec 2024
Encrypting and Decrypting Text Using RSA in PHP without PaddingQuestion:Is there a PHP 5.3 class that facilitates RSA encryption and decryption...

28 Nov 2024
Secure Encryption and Decryption with PyCrypto AES-256PyCrypto is a robust library for cryptographic operations in Python. One common task is to...

19 Apr 2025
Go language implements the encryption and decryption of SM4 and SM2 in Go language. This article will introduce in detail how to use Go language to implement the encryption and decryption process of the encryption and decryption of SM4 and SM2 algorithms in Go language to meet the needs of Java...


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
