Home >PHP Framework >Swoole >Can swoole encryption be cracked?
The execution of the program and the encryption and decryption process are unified. No matter it is attacked by internal developers or external hackers, even if they get the data and private keys and the root permissions of the server, they can still Unable to decrypt restore data.
Swoole divides encryption and decryption into 3 parts (program, algorithm, private key), one of which is indispensable for decryption. Only the PHP program compiled and generated by the corresponding Swoole Compiler can decrypt the data.
Swoole Compiler data encryption uses asymmetric encryption and requires the generation of public and private keys. Swoole Compiler provides two functions to implement encryption and decryption. These two functions must be used in encrypted programs and cannot be used in unencrypted PHP programs.
The data encryption module requires additional payment, the price is 30% of the Compiler
Generate public and private keys
swoole-compiler gen-keypair
After successful execution , two files, public_key and private_key, will be generated in the current directory.
public_key public key, used for encryption
private_key private key, used for decryption
Data encryption
$encryptedData = swoole_encrypt($oriData, "./public_key");
Data decryption
$oriData = swoole_decrypt($encryptedData, "./private_key");
Applicable scenarios
Swoole Compiler data encryption is very suitable for background programs that are sensitive to data security, such as storing user bank cards and ID cards. number and other user privacy information. Use Swoole Compiler to encrypt data and store it in the database.
Recommended learning: swoole video tutorial
The above is the detailed content of Can swoole encryption be cracked?. For more information, please follow other related articles on the PHP Chinese website!