<?php class Xcrypt{ private $mcrypt; private $key; private $mode; private $iv; private $blocksize; public function __construct($key, $mode = 'cbc', $iv = "off"){ switch (strlen($key)){ case 8: $this->mcrypt = MCRYPT_DES; break; case 16: $this->mcrypt = MCRYPT_RIJNDAEL_128; break; case 32: $this->mcrypt = MCRYPT_RIJNDAEL_256; break; default: die("Key size must be 8/16/32"); }
Commonly used symmetric encryption algorithm class
Supported key: 64/128/256 bit (byte length 8/16/32)
Supported algorithm: DES/AES (according to the key Key length automatic matching uses: DES: 64bit AES: 128/256bit)
Supported mode: CBC/ECB/OFB/CFB
Ciphertext encoding: base64 string/hexadecimal character String/binary string stream
Padding method: PKCS5Padding (DES)
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
11 Jul 2016
A recent project requirement is to use PHP to generate an encrypted string from some ordinary information through an encryption algorithm. The encrypted string can parse out the previous information through the decryption algorithm (reverse). Since I have never done it before, I would like to ask friends here if they have any ideas for ready-made encryption and decryption algorithms. The algorithm needs to be complex enough and not easy to be cracked. It would be better if there is a specific code.
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...
13 Dec 2024
Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...
28 Oct 2024
Suppression of Tensorflow Debugging OutputTensorflow prints extensive information about loaded libraries, found devices, and other debugging data...
03 Jan 2025
Overflow: Hidden and Expansion of HeightjQuery distinguishes itself from other JavaScript libraries through its cross-platform compatibility and...
30 Oct 2024
Native Java Image Processing Libraries for High-Quality ResultsAs you have encountered limitations with ImageMagick and JAI, let's explore other...
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