-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathexample_usage.php
More file actions
30 lines (22 loc) · 792 Bytes
/
example_usage.php
File metadata and controls
30 lines (22 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
//Include the library
require_once 'AESCryptFileLib.php';
//Include an AES256 Implementation
require_once 'aes256/MCryptAES256Implementation.php';
//Construct the implementation
$mcrypt = new MCryptAES256Implementation();
//Use this to instantiate the encryption library class
$lib = new AESCryptFileLib($mcrypt);
//This example encrypts and decrypts the README.md file
$file_to_encrypt = "README.md";
$encrypted_file = "README.md.aes";
$decrypted_file = "README.decrypted.txt";
//Ensure target file does not exist
@unlink($encrypted_file);
//Encrypt a file
$lib->encryptFile($file_to_encrypt, "1234", $encrypted_file);
//Ensure file does not exist
@unlink($decrypted_file);
//Decrypt using same password
$lib->decryptFile($encrypted_file, "1234", $decrypted_file);
echo "Done";