Share a newly written PHP encryption and decryption function
XOR string encryption method after base64 encryption
Encryption
function encode($str,$key) { $res = base64_encode($str); $code = $res^$key; return $code; }
Decryption
function decode($str,$key) { return base64_decode($str^$key); }
Full code example:
$str = '111021'; $key = 'APPYJJ-PHONE-LAZY'; function encode($str,$key) { $res = base64_encode($str); $code = $res^$key; return $code; } $str = encode($str,$key); print_r($str); echo "<hr>"; function decode($str,$key) { return base64_decode($str^$key); } print_r(decode($str,$key));
The whole program is very simple~ According to logical thinking, it should be difficult to crack, if others don’t know your secret key;
If you still feel unsafe. So I’m just going to throw some light here; I suggest you continue to use shift operations in the encryption and decryption process
//加密的时候; $a = $str >> 4; //解密的时候则相反 $a = $str << 4;
ok!~ At this point, the blogger continues to work! ~~
XOR string encryption method after base64 encryption
Encryption
function encode($str,$key) { $res = base64_encode($str); $code = $res^$key; return $code; }
Decryption
function decode($str,$key) { return base64_decode($str^$key); }
Complete code example:
$str = '111021'; $key = 'APPYJJ-PHONE-LAZY'; function encode($str,$key) { $res = base64_encode($str); $code = $res^$key; return $code; } $str = encode($str,$key); print_r($str); echo "<hr>"; function decode($str,$key) { return base64_decode($str^$key); } print_r(decode($str,$key));
The whole program is very simple ~ according to logical thinking, it should be difficult to crack, in others Without knowing your secret key;
If you still feel unsafe. So I’m going to throw some light here; I suggest you continue to use shift operations in the encryption and decryption process
//加密的时候; $a = $str >> 4; //解密的时候则相反 $a = $str << 4;
For more related articles about sharing a newly written PHP encryption and decryption function, please pay attention to PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

The latest version of Laravel10 is compatible with MySQL 5.7 and above, PostgreSQL 9.6 and above, SQLite 3.8.8 and above, SQLServer 2017 and above. These versions are chosen because they support Laravel's ORM features, such as the JSON data type of MySQL5.7, which improves query and storage efficiency.

NGINX and Apache each have their own advantages and disadvantages, and the choice should be based on specific needs. 1.NGINX is suitable for high concurrency scenarios because of its asynchronous non-blocking architecture. 2. Apache is suitable for low-concurrency scenarios that require complex configurations, because of its modular design.

The session realizes user authentication through the server-side state management mechanism. 1) Session creation and generation of unique IDs, 2) IDs are passed through cookies, 3) Server stores and accesses session data through IDs, 4) User authentication and status management are realized, improving application security and user experience.

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

DMA in C refers to DirectMemoryAccess, a direct memory access technology, allowing hardware devices to directly transmit data to memory without CPU intervention. 1) DMA operation is highly dependent on hardware devices and drivers, and the implementation method varies from system to system. 2) Direct access to memory may bring security risks, and the correctness and security of the code must be ensured. 3) DMA can improve performance, but improper use may lead to degradation of system performance. Through practice and learning, we can master the skills of using DMA and maximize its effectiveness in scenarios such as high-speed data transmission and real-time signal processing.
