search
Homephp教程php手册PHP自学教程之PHP加密函数

PHP自学教程之PHP加密函数

Jun 06, 2016 pm 07:54 PM
phpfunctionencryptionprincipleBasicTutorialdataSelf-study

数据加密的基本原理就是对原来的明文的文件或数据按某种算法进行处理,使其成为不可读的一定代码,通常称为“密文”,通过这样的途径来达到保护数据不被非法窃取和阅读目的。 PHP加密的函数主要有:crypt()、md5()和sha1()函数,还有加密的拓展库Mcrypt和Mas

                  数据加密的基本原理就是对原来的明文的文件或数据按某种算法进行处理,使其成为不可读的一定代码,通常称为“密文”,通过这样的途径来达到保护数据不被非法窃取和阅读目的。

                  PHP加密的函数主要有:crypt()、md5()和sha1()函数,还有加密的拓展库Mcrypt和Mash。这里主要介绍:crypt()、md5()和sha1()

PHP相关代码:

<?php //crypt()函数加密
      $content="12345678";
      echo '加密前$content的值为:'.$content."<br/>";
     $crypt=crypt($content);
      echo '加密后$crypt的值为:'.$crypt."<br>";
      echo"<br>";
      //md5()函数加密
      $md5="12345678";
      echo '加密前$md5的值为:'.$md5."<br>";
      $md5s=md5($md5);
      echo '加密后$md5s的值为:'.$md5s."<br>";
      echo"<br>";
      //sha1()函数加密
      $sha1="12345678";
      echo '加密前$sha1的值为:'.$sha1."<br>";
      $sha1s=sha1($sha1);
      echo '加密后$sha1s的值为:'.$sha1s."<br>";
?>

结果展示:

PHP自学教程之PHP加密函数

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),