<?php class crypt { private $skey; public function __construct($key) { $this->skey = hash("md5", $key, true); //32位skey } public function safe_b64encode($string) { $data = base64_encode($string); $data = str_replace(array('+', '/', '='), array('-', '_', ''), $data); return $data; } public function safe_b64decode($string) { $data = str_replace(array('-', '_'), array('+', '/'), $string); $mod4 = strlen($data) % 4; if ($mod4) { $data .= substr('====', $mod4); } return base64_decode($data); }
This is a PHP encryption and decryption class. Friends who need it can download and use it
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
12 Jul 2016
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 /*==========
12 Jul 2016
DES encryption and decryption example code implemented by PHP, phpdes encryption and decryption example. DES encryption and decryption example code implemented by PHP, phpdes encryption and decryption example This article describes an example of DES encryption and decryption implemented by PHP. Share it with everyone for your reference, the details are as follows: php$key
06 Jul 2016
PHP blowfish encryption and decryption function
25 Nov 2024
RSA encryption and decryption without padding in PHP Question: In PHP 5.3, is there a way to provide RSA without padding...
12 Dec 2024
This guide explains how to implement encryption and decryption of sensitive data in Laravel models. By performing the following steps, you can protect the data before storing it in the database and decrypt it when retrieving the data.
12 Dec 2024
This guide explains how to implement encryption and decryption for sensitive data in Laravel models. By following these steps, you can secure data before storing it in the database and decrypt it when retrieving it.
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images