Home Backend Development PHP Tutorial Discuz经典的用户信息加密算法

Discuz经典的用户信息加密算法

Jun 20, 2016 pm 01:01 PM
php encryption

Discuz经典的用户信息加密算法

/**
 *用户信息加密解密函数
 *
 *待加密内容用/t分割
 *@return String 加密或解密字符串
 *@param String $string 待加密或解密字符串
 *@param String $operation 操作类型定义 DECODE=解密 ENDODE=加密
 *@param String $key 加密算子
 */
function authcode($string, $operation, $key = '') {
/**
 *获取密码算子,如未指定,采取系统默认算子
 *默认算子是论坛授权码和用户浏览器信息的md5散列值
 *$GLOBALS['discuz_auth_key']----全局变量
 *取值为:md5($_DCACHE['settings']['authkey'].$_SERVER['HTTP_USER_AGENT'])
 *$_DCACHE['settings']['authkey']是论坛安装时生成的15位随机字符串
 */
    $key = md5($key ? $key : $GLOBALS['discuz_auth_key']);
    $key_length = strlen($key);
/**
 *如果解密,先对密文解码
 *如果加密,将密码算子和待加密字符串进行md5运算后取前8位
 *并将这8位字符串和待加密字符串连接成新的待加密字符串
 */
    $string = $operation == 'DECODE' ? base64_decode($string) : substr(md5($string.$key), 0, 8).$string;
    $string_length = strlen($string);
    $rndkey = $box = array();
    $result = '';
  
/**
 *初始化加密变量,$rndkey和$box
 */
    for($i = 0; $i <p class="item-note"><br></p>
Copy after login
Statement of this Website
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 Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP encryption and decryption methods and solutions to common problems PHP encryption and decryption methods and solutions to common problems Jun 09, 2023 pm 01:50 PM

PHP encryption and decryption methods and solutions to common problems

How PHP implements data encryption, decryption and transmission to ensure data security How PHP implements data encryption, decryption and transmission to ensure data security Jun 27, 2023 am 10:44 AM

How PHP implements data encryption, decryption and transmission to ensure data security

How to use PHP encryption technology to protect the registration process and prevent registration fraud How to use PHP encryption technology to protect the registration process and prevent registration fraud Aug 19, 2023 pm 12:05 PM

How to use PHP encryption technology to protect the registration process and prevent registration fraud

Methods and techniques for data encryption and decryption using PHP arrays Methods and techniques for data encryption and decryption using PHP arrays Jul 16, 2023 pm 04:02 PM

Methods and techniques for data encryption and decryption using PHP arrays

PHP development skills: How to implement data encryption and decryption functions PHP development skills: How to implement data encryption and decryption functions Sep 21, 2023 am 08:51 AM

PHP development skills: How to implement data encryption and decryption functions

Encryption and decryption in PHP Encryption and decryption in PHP May 26, 2023 pm 12:51 PM

Encryption and decryption in PHP

Encryption and decryption technology in PHP and solutions to common problems Encryption and decryption technology in PHP and solutions to common problems Jun 09, 2023 pm 12:36 PM

Encryption and decryption technology in PHP and solutions to common problems

Analysis of encryption and decryption technology of PHP security sensitive data Analysis of encryption and decryption technology of PHP security sensitive data Jun 30, 2023 pm 02:01 PM

Analysis of encryption and decryption technology of PHP security sensitive data

See all articles