Encrypt and Decrypt string by giving private-key before doing encryption, and insert public-key & private-key for decrypting.
You can install this directly from github, or you can install it via composer. But, we recommend you to install this library via composer.
- Install composer
If you don't know how to install composer, you can read this: Install Composer - Make your project directory / go to your project directory.
- Install by composer
Open your terminal, go to your project directory, and paste this code:
composer require fikoborizqy/bose-crypt
- Include the composer
autoload.php
Open your php project file, and put this on top of your code.
require_once('vendor/autoload.php');
When you encrypting data, you need to decide private-key for the plain-text. Let's crack on:
- use Bose Class by the namespace
copy this before you encrypting data! You can change this$class
variable as you want.
$class = new \Borizqy\Bose\Bose();
- Encrypting data
To encrypt data, you need to decide the private-key. This private key will be used to encrypt and decrypt data:
$example = $class->encrypt("text example", "this my key", "a", "y");
The output will be of encryption above will be like this:
Object (
[plain_text] => text example
[cipher_text] => 01101000101100011000101101110011111001111000010010010101111010111111101111101001111101011000011110000111010010111010101
[public_key] => 71f7b10vTacnxhz10PgRNQLca10C4amZveG10vlIg7ygo10DQMy72cc10IAQAOJya10u2KMZZ1F10E2K0VHbY10G2oGPVPQ10u2KMZZ1F10E1Rr8N7410I1DvgxBE100iCUmdg1
[private_key] => this my key
)
- Decrypting data
To decrypt data, you need to prepare cipher-text, public-key, and private-key.
$example = $class->decrypt("01101000101100011000101101110011111001111000010010010101111010111111101111101001111101011000011110000111010010111010101", "this my key", '71f7b10vTacnxhz10PgRNQLca10C4amZveG10vlIg7ygo10DQMy72cc10IAQAOJya10u2KMZZ1F10E2K0VHbY10G2oGPVPQ10u2KMZZ1F10E1Rr8N7410I1DvgxBE100iCUmdg1');
The output will be of decryption above will be like this:
Object (
[plain_text] => text example
[cipher_text] => 01101000101100011000101101110011111001111000010010010101111010111111101111101001111101011000011110000111010010111010101
[public_key] => 71f7b10vTacnxhz10PgRNQLca10C4amZveG10vlIg7ygo10DQMy72cc10IAQAOJya10u2KMZZ1F10E2K0VHbY10G2oGPVPQ10u2KMZZ1F10E1Rr8N7410I1DvgxBE100iCUmdg1
[private_key] => this my key
)