PHP code example of kevchikezie / cryptographer

1. Go to this page and download the library: Download kevchikezie/cryptographer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kevchikezie / cryptographer example snippets


use Kevchikezie\Cryptographer;

$plainValue = 'hello';

$publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzuQVNe0DQC5SCh31fsSa fki5Q7wCHN6LGEnPu9BRV6lX0SrLcGwyHuIOPGrGEDYkgqjAZmh1aMy1yh48WiyJ KUrPvkFx0SNIOjr8zkBCsiCLxsmO8W7+ESDrhejE/B1qtaEKOIjaa012/d5hbt+W QDQBoFy8w4uWrrg9z4iQPpNd5w/sfkOwM4jB2zQ0beEo7yR1+n6iMN4NKmleJseZ er9BLnpT65mDkBoLaWvQVAphknd9pzKymkukf0cA1BqRBeC8z3sGG7fyCdvhNnSV H3GNEsNl/QtCCEedV30xdJtTYMErD+5uwLv2JtGfnhV8SO/FJck1aU4V+hoRIvO1 rwIDAQAB";

$encryptedValue = Cryptographer::encrypt($plainValue, $publicKey);
var_dump($encryptedValue);

/*
# Returns
gKwBnIKJslYNrW8W7fDqiQddtl3NIOqauPo0KCOvdrn1OqyqbGJsuxPpc4FBjQt173zfaZAKduBehbYUVhZ83pobRXTo/HjWJv6mmftHkU1SqI47krNjIgBylVWv295G11nxGZH6eKGqdVuF5pVDGFUUZcRQhY/AM0tbfTfnqLMIDS12KE7rPVlRymLLGeereknXsLf7AmhYD8GIVwI/ozey4eOfXyn/Rf44xa2gruFdzTusHB64WNOY1YX/mjFTpPSSqRG5mMnw3bL4DKNC2fEB/Y0fx6F4xGCepXcuMV+otmaHLt+jaPnTJBJSmJAHHKaWsrM/H7Wvm+ayY3Y/Ww==
*/

use Kevchikezie\Cryptographer;

$plainValues = [
	'name' => 'John Doe', 
	'email' => '[email protected]'
];

$publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzuQVNe0DQC5SCh31fsSa fki5Q7wCHN6LGEnPu9BRV6lX0SrLcGwyHuIOPGrGEDYkgqjAZmh1aMy1yh48WiyJ KUrPvkFx0SNIOjr8zkBCsiCLxsmO8W7+ESDrhejE/B1qtaEKOIjaa012/d5hbt+W QDQBoFy8w4uWrrg9z4iQPpNd5w/sfkOwM4jB2zQ0beEo7yR1+n6iMN4NKmleJseZ er9BLnpT65mDkBoLaWvQVAphknd9pzKymkukf0cA1BqRBeC8z3sGG7fyCdvhNnSV H3GNEsNl/QtCCEedV30xdJtTYMErD+5uwLv2JtGfnhV8SO/FJck1aU4V+hoRIvO1 rwIDAQAB";

$encryptedValues = Cryptographer::encrypt($plainValues, $publicKey);
var_dump($encryptedValues);

/*
# Returns an array of encrypted data
[
	"name" => "f2fdeNgjlwqPURHRC0ddXHY29m6znEHyQkq76om8I3q/Ixx/CZcs1fmnuPRalVE9kYLG9RfP2cixo+wGTVNHWm5kR0dGVQ9rX0LdsKbe/VmVZSF40qZdszJJ90AN3+DXU+iMb6Zm4/zogwRI4IgmnVI6G1cGbHR7AKHycOY7DBxrMnkfc65zEpi0Vhhq/V7XZJ/KZy6SicSt0nWgoIrj6xjYM9UiejRQuxNobtJ+E15ypXqvyD276FTaouXQD3yyQ0brYAaFPh00jwGyV8hcRzmSo33fOHm8QBNtSScAKRDR42Vfmy29GQbeVjZNz7ObEL43QovAbtDiOwRt2noXTQ==", 

	"email" => "T9NknfUKZeMOF17YojRvFykr6vy6Zhygo/RspPW3DOTfMYKCgcdiCXIhv+jBMY/jSZDOyD8XZKx0Co3/Kc4KFMPkhNC/3mBDmXwUNL0msavs11HVtonpFnchggkjGd2Y3xjfkSXG2Ah585AGg8h+/YVrsxqWCOMMOxRwueHREycDSai6pQcbQBuHGYUpHrxIA7vWS03ygvQyHVu+84D5BUy3Bh0D0ix3qi9qP/+26fUK2OmH7cLMHUAilS2tZ05zLVO1LIZaMc+fUTMth2Y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MTEyJfWB5wWgtqhjWD90+zI SufNXi3Qis+U2kmbjp6CoEdgTPsYLGfWgLyI+AEsH2w6HaxG9A6DuELZW2YaYBwp pqy6ngmlK46JTMkitJxogTcC4XaXVLemIqWI/Pca2QKBgQDwZjTyyX5Y04S6W6RC sMTWMW0De4gRHtVFnrn3ZF6hH86pf9UGmq05N+3HG1qXpzXthKDByGstauSr56qT aq2FcYiFNWCpU7OS3tuccx3YO072rNONws9oFWRafUFIL8N0gaqy3y9QK02U27ms ziGRzjZ+CX9IBSU3O8F9VIPmdQKBgQDcUTJxexRA4CS43jmRoZS5i4Ojbx/wSYZZ opMs90y40p0bZy6ANrHPgpkgK31bZTyIWux0NF1CDa7CuSCITUPIIISAtvEkk50p u6K11RKk0yXPgXAuHPbn7oh9vBfWrW3QrRA6LxHs2rNJEvDxqqtD5qZKU1QhTLqG TEGs/m3PEwKBgCUvGfeH1SQ2K2yL6j9qije7U2pbfDNxunlXUNqESuLPQa8UF8Y6 vJqCHSRUBdI5Se0gO6Fdt75Br3crkUXWFVrzsbMxC2+Fg9wu3nc3kyE0I0Wie+KM hHpL/MbGYwegY7IssFOUlAPpfsmMpw6kn6qm4+Tg4TApo5UEiCwzm2dVAoGBAKif vOv+N9Ivu+uCqq077ojUrzw3oUpX++w+8kZIQQB0sqp2nrCjLBSW8HwezSNWqK30 aWXHbllP/6Ip7yxjdq2FteSOIKLOGEwIwNBK9KoSsa3Qc/vXT2LUvsL9Y4F728EL tI/T1vRhrzcOuDs/VTXzIvNgM9QI1fpUAzBUy9bhAoGAfhnLkZZKppYOVuprwOO4 mvgv4H9JatHGn0BA3fXJNdKdzC0jVDwWQKukPSU7zXzRNMPkXSHVI9QsgQjrAkFd dY1JALe+Rj1qN0Cn4b6Jz01q9Nl2kti/pxJH8YjIml5gNvQokL/8yohco0V5tk16 vnX+E9I9EdcGiAGGpWq83rQ=";

$decryptedValue = Cryptographer::decrypt($encryptedValue, $privateKey);
var_dump($decryptedValue);

/*
# Returns
hello
*/

use Kevchikezie\Cryptographer;

$encryptedValues = [
	"name" => "f2fdeNgjlwqPURHRC0ddXHY29m6znEHyQkq76om8I3q/Ixx/CZcs1fmnuPRalVE9kYLG9RfP2cixo+wGTVNHWm5kR0dGVQ9rX0LdsKbe/VmVZSF40qZdszJJ90AN3+DXU+iMb6Zm4/zogwRI4IgmnVI6G1cGbHR7AKHycOY7DBxrMnkfc65zEpi0Vhhq/V7XZJ/KZy6SicSt0nWgoIrj6xjYM9UiejRQuxNobtJ+E15ypXqvyD276FTaouXQD3yyQ0brYAaFPh00jwGyV8hcRzmSo33fOHm8QBNtSScAKRDR42Vfmy29GQbeVjZNz7ObEL43QovAbtDiOwRt2noXTQ==", 

	"email" => "T9NknfUKZeMOF17YojRvFykr6vy6Zhygo/RspPW3DOTfMYKCgcdiCXIhv+jBMY/jSZDOyD8XZKx0Co3/Kc4KFMPkhNC/3mBDmXwUNL0msavs11HVtonpFnchggkjGd2Y3xjfkSXG2Ah585AGg8h+/YVrsxqWCOMMOxRwueHREycDSai6pQcbQBuHGYUpHrxIA7vWS03ygvQyHVu+84D5BUy3Bh0D0ix3qi9qP/+26fUK2OmH7cLMHUAilS2tZ05zLVO1LIZaMc+fUTMth2YmADYFcd2JzNuawMjm+qVkWYhcUvSqDWx2g6Sh4E2151YMDQ+aENlfnsTXVrvUxxpkyQ==" 
];

$privateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDO5BU17QNALlIK HfV+xJp+SLlDvAIc3osYSc+70FFXqVfRKstwbDIe4g48asYQNiSCqMBmaHVozLXK HjxaLIkpSs++QXHRI0g6OvzOQEKyIIvGyY7xbv4RIOuF6MT8HWq1oQo4iNprTXb9 3mFu35ZANAGgXLzDi5auuD3PiJA+k13nD+x+Q7AziMHbNDRt4SjvJHX6fqIw3g0q aV4mx5l6v0EuelPrmYOQGgtpa9BUCmGSd32nMrKaS6R/RwDUGpEF4LzPewYbt/IJ 2+E2dJUfcY0Sw2X9C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EL tI/T1vRhrzcOuDs/VTXzIvNgM9QI1fpUAzBUy9bhAoGAfhnLkZZKppYOVuprwOO4 mvgv4H9JatHGn0BA3fXJNdKdzC0jVDwWQKukPSU7zXzRNMPkXSHVI9QsgQjrAkFd dY1JALe+Rj1qN0Cn4b6Jz01q9Nl2kti/pxJH8YjIml5gNvQokL/8yohco0V5tk16 vnX+E9I9EdcGiAGGpWq83rQ=";

$decryptedValues = Cryptographer::encrypt($encryptedValues, $privateKey);
var_dump($decryptedValues);

/*
# Returns an array of decrypted data
[
	'name' => 'John Doe', 
	'email' => '[email protected]'
]
*/

use Kevchikezie\Cryptographer;

$keys = Cryptographer::generate();
var_dump($keys);

/*
# Returns an array containing the private and public RSA keys
[
	"private" => "-----BEGIN PRIVATE KEY----- MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDD+qw31M0e5Gfa kgeR/ezMRF+EOMhmXQuAyr7oXksfzAHmDPLJLKtsg8cp6ToGuZ8uEzrqer5t7rLy m90EtKTvWtV7vg3Tk/lySXTMOUiOOAttms4Re5/nd5Oees7n7YDbHQ0cVEwhrFbf k4J0nV7SnUFV/RFTpgBOHDpFlT6zsJWLI7QPfjzCbza2YzSiuna4zn0xsjJCf23I XwXmehy+VBl8YGuyPJPxqiPMkd2HLNvc97SfSTi+0O5Y4UXBeDuuKAq/b8P80MM5 JD3/x6rH+wYGUJ3XJYwg+4yRnqpm/q16p9qLloVz9jR/8Cb1z06c3rB5eaKnlGbP w08uZKoRAgMBAAECggEAWrl57mK6DnoIRdviW0hkze89FJXA1/ps79Nr62BzgKXN nzURU+Y0+YhLs/A/J4vYz9ihJplp/LRK7RsQhzQlQpUXTTCfb/oJuUmeI0jFeOkj CTtn+Bn13Y6yrOQHUsDVLRpWzm2LzO7eTKQZ+Wg81F1uOKNt2P55F6/jngDIRSBC 3fQTdg3o6664T2FlWjcKjBSwZhNIMehSRkpj2h6wKwDNNvFbX0Lw167Bj0Zu7sDN cymQJu/Ey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HuRn2pIHkf3s zERfhDjIZl0LgMq+6F5LH8wB5gzyySyrbIPHKek6BrmfLhM66nq+be6y8pvdBLSk 71rVe74N05P5ckl0zDlIjjgLbZrOEXuf53eTnnrO5+2A2x0NHFRMIaxW35OCdJ1e 0p1BVf0RU6YAThw6RZU+s7CViyO0D348wm82tmM0orp2uM59MbIyQn9tyF8F5noc vlQZfGBrsjyT8aojzJHdhyzb3Pe0n0k4vtDuWOFFwXg7rigKv2/D/NDDOSQ9/8eq x/sGBlCd1yWMIPuMkZ6qZv6teqfai5aFc/Y0f/Am9c9OnN6weXmip5Rmz8NPLmSq EQIDAQAB -----END PUBLIC KEY----- "
]
*/

use Kevchikezie\Cryptographer;

$keys = Cryptographer::generate('512'); //'512', '1024', '2048', '4096'
var_dump($keys);

/*
# Returns an array containing the private and public RSA keys
[
	"private" => "-----BEGIN PRIVATE KEY----- MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAt9jKfaObXteXGEZY 8BwOjw5vTsERVe89BC5miQeNb8EdSsj6YMTRBz0gojDvwQOlDjQTykVPTyEI4kz3 Kixt+QIDAQABAkAnFpLG77gjDBd1888JDg4SYHFN/0KeUMVaVDs8uzxZHAvDFUio GBPEVgGsfrAwaX3aGFU34zVHVi1VIo5GSVwBAiEA3vSM7Gp7m1om3U15AUrQfgva udNejyHIhHkyslslljkCIQDTGF/GboBBdqwbhvqAD4Eeo5THt3jmRXXTwUFNbZ+V wQIgYNO4OBxuniNi6Y1x1dvV/EfNsBJZ6LN1UAMKv2bSRhECIQCrDt5Vmye9ZKAU 8m09ptK39FDVAj0rRHA1ty3mw4WFQQIhAMKRYiOaU+NLIoGmIi4jgOZ1zpa+iel3 yfzQ7Pmp6rUY -----END PRIVATE KEY----- ", 

	'public' => "-----BEGIN PUBLIC KEY----- MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALfYyn2jm17XlxhGWPAcDo8Ob07BEVXv PQQuZokHjW/BHUrI+mDE0Qc9IKIw78EDpQ40E8pFT08hCOJM9yosbfkCAwEAAQ== -----END PUBLIC KEY----- "
]
*/