<?php
$key="12";//your secret key to encode files
$iv="12";
function encryptFile2($textToEncrypt, $key, $iv) {
    //$plaintext = file_get_contents($fileToEncrypt);
    $ciphertext = openssl_encrypt($textToEncrypt, 'aes-256-cbc', $key, $options=0, $iv);
    //file_put_contents($fileToEncrypt . '.enc', $ciphertext);
    return $ciphertext;
}
function decryptFile2($textToDecrypt, $key, $iv) {
    //$ciphertext = file_get_contents($encryptedFile);
    $plaintext = openssl_decrypt($textToDecrypt, 'aes-256-cbc', $key, $options=0, $iv);
    //file_put_contents(str_replace('.enc', '', $encryptedFile), $plaintext);
    return $plaintext;
}
function safeDeletion($targetFile){
	file_put_contents($targetFile,"",LOCK_EX);
	unlink($targetFile);
}
function encryptFile($fileToEncrypt){
$encoded_image =  base64_encode(file_get_contents($fileToEncrypt));
file_put_contents($fileToEncrypt . '.enc', encryptFile2($encoded_image,$key,$iv),LOCK_EX);
}
function decryptFile($fileToDecrypt){
$encoded_image =  file_get_contents($fileToDecrypt.'.enc');
file_put_contents($fileToDecrypt, base64_decode(decryptFile2($encoded_image,$key,$iv)),LOCK_EX);
}
?>
