PHP code example of maymeow / cryptography

1. Go to this page and download the library: Download maymeow/cryptography 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/ */

    

maymeow / cryptography example snippets


$csp = new AESCryptoServiceProvider();
$csp->generateIV();
$key = $csp->generateKey();

$plainText = "This is going to be encrypted!";
$encryptedText= $csp->encrypt($plainText);

$csp2 = new AESCryptoServiceProvider();
$csp2->setKey($key);
$decryptedText = $csp2->decrypt($encryptedText);

$plainText = "This is going to be encrypted!";
$parameters = new RSAParameters();
$parameters->generateKeys("passphrase"); // generating key pair (private and public keys)

$rsa = new RSACryptoServiceProvider();
$rsa->setParameters($parameters);

$encryptedTest = $rsa->encrypt($plainText);

$decryptedText = $rsa->decrypt($encryptedTest);

 $parameters = new RSAParameters();
$parameters->generateKeys();
$locator = new TestingParametersLocator();

$writer = new RsaParametersWriter($locator);
$writer->write($parameters);

$reader = new RsaParametersReader($locator);
$parameters2 = $reader->read();

$csp2 = new RSACryptoServiceProvider();
$csp2->setParameters($parameters2);

$p = new Maymeow\Cryptography\CryptoKey();

$p->getCryptograhicKey($password, $salt);