php encryption function
This article mainly introduces the encryption function of PHP, which has certain reference value. Now I share it with everyone. Friends in need can refer to it
In the development process of the website , it is often necessary to encrypt some data (such as user passwords). This article mainly introduces several common encryption functions of PHP. Friends who need it can refer to it
MD5 encryption:
string md5 ( string $str [, bool $raw_output = false ] )
1.md5() defaults to 32 characters Returns the hash value in hexadecimal digital form. It accepts two parameters. The first is the string to be encrypted, and the second is the Boolean value of raw_output. The default is false. If set to true, md5() will Returns the original 16-bit binary format message digest
2.md5() is a one-way encryption, there is no reverse decryption algorithm, but some common strings can still be cracked through collection, enumeration, collision, etc.
1234
5 6 7 8 9 10 11 12 13 14 15 16 |
Copy after login |
Crypt encryption:
string crypt ( string $str [, string $salt ] )
1.crypt() accepts two parameters, the first is the string that needs to be encrypted, and the second one is the salt value (which is the encryption interference value, if not provided, it is automatically generated by PHP by default); returns a hashed string or a string of less than 13 characters, the latter To distinguish the salt value.
2.crypt() is one-way encryption, the same as md5.
123456 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
Copy after login |
Sha1 encryption:
string sha1 ( string $str [, bool $raw_output = false ]
1. It is very similar to md5, but the difference is sha1( ) returns a 40-character hash value by default. The parameters passed in are of the same nature. The first one is the encrypted string, and the second one is the Boolean value of raw_output. The default is false. If set to true, sha1() will Will return the original 20-bit original format message digest
2.sha1() is also single-line encryption, there is no reverse decryption algorithm
1 2 3 4 5 6 7 8 9 |
Copy after login |
Urlencode encryption:
string urlencode ( string $str )
1. One parameter, pass in the string to be encrypted (usually used to encrypt URLs),
2. Urlencode is a two-way encryption, which can be encrypted with urldecode (strictly speaking, it is not a real encryption)
3. Return a string, all non-letters in this string except -_. Numeric characters will be replaced with a percent sign (%) followed by two hexadecimal digits, and spaces will be encoded as a plus sign ( ).
123456 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
Copy after login |
base64 encoding encryption:
string base64decode (string $encodeddata)
1.base64_encode() accepts a parameter, which is the data to be encoded (strings are not mentioned here) , because base64 is often used to encode images)
2.base64encode() is a two-way encryption, and base64decode() can be used to decrypt
##12345678 9 10 11 12 13 |
Copy after login |
An example of a picture:
12345678910 11 |
Copy after login |
相关推荐:
The above is the detailed content of php encryption function. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

The following resources contain additional information on CakePHP. Please use them to get more in-depth knowledge on this.
