PHP code example of garsaud / cryptstreamaes

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

    

garsaud / cryptstreamaes example snippets


use Garsaud\CryptStreamAES\AES;
use Garsaud\CryptStreamAES\Length;

$aes = new AES(Length::AES256);

$aes->encrypt(
    key: 'B374A26A71490437AA024E4FADD5B497FDFF1A8EA6FF12F6FB65AF2720B59CCF',
    inputStream: fopen('myfile.jpg', 'rb'),
    outputStream: fopen('myfile-encrypted.bin', 'wb'),
);

use Garsaud\CryptStreamAES\AES;
use Garsaud\CryptStreamAES\Length;

$aes = new AES(Length::AES256);

$aes->decrypt(
    key: 'B374A26A71490437AA024E4FADD5B497FDFF1A8EA6FF12F6FB65AF2720B59CCF',
    inputStream: fopen('myfile-encrypted.bin', 'rb'),
    outputStream: fopen('myfile.jpg', 'wb'),
);