search
HomePHP LibrariesOther librariesPHP class for symmetric encryption algorithm
PHP class for symmetric encryption algorithm
<?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)


Disclaimer

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

Asking for the use of PHP encryption and decryption algorithmAsking for the use of PHP encryption and decryption algorithm

11Jul2016

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.

Is There a PHP 5.3 Class for Unpadded RSA Encryption/Decryption?Is There a PHP 5.3 Class for Unpadded RSA Encryption/Decryption?

25Nov2024

RSA encryption and decryption without padding in PHP Question: In PHP 5.3, is there a way to provide RSA without padding...

How Do I Link Static Libraries That Depend on Other Static Libraries?How Do I Link Static Libraries That Depend on Other Static Libraries?

13Dec2024

Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

How to Silence TensorFlow\'s Debugging Output?How to Silence TensorFlow\'s Debugging Output?

28Oct2024

Suppression of Tensorflow Debugging OutputTensorflow prints extensive information about loaded libraries, found devices, and other debugging data...

How Does jQuery Simplify DOM Manipulation for Web Developers?How Does jQuery Simplify DOM Manipulation for Web Developers?

03Jan2025

Overflow: Hidden and Expansion of HeightjQuery distinguishes itself from other JavaScript libraries through its cross-platform compatibility and...

Which native Java image processing library is right for you?Which native Java image processing library is right for you?

30Oct2024

Native Java Image Processing Libraries for High-Quality ResultsAs you have encountered limitations with ImageMagick and JAI, let's explore other...

See all articles