public static function qnckDecrytp($string) { $keyStr = Config::get('app.AES.key'); $aes = new AESCrypt(); $aes->set_key($keyStr); $aes->require_pkcs5(); $re = $aes->decrypt($string); return $re; }
// class $passphrase = 'ThisIsMySecretPassphrase'; // Initializing the class $crypt = new AESCrypt($passphrase); // Setting date and time $date = date("Y-m-d"); echo nl2br("Date: " . $date . "\n"); $time = date("H:i:s"); echo nl2br("Time: " . $time . "\n"); // Adding date and time to the header // of the encrypted file $crypt->setExtText(array($crypt::CREATED_DATE => $date, $crypt::CREATED_TIME => $time)); // File to encrypt //$file = 'path/to/my/file/file.txt'; $file = 'readme.txt'; echo nl2br("Encryption of the file: " . $file . "\n"); // read content $data = file_get_contents($file); // encrypt and write to a new file (existing file is overwritten) file_put_contents($file . '.aes', $crypt->encrypt($data)); echo nl2br("AES-file encryption finished" . "\n"); echo nl2br("============================" . "\n"); echo nl2br("AES-file decryption starts" . "\n"); echo nl2br("============================" . "\n"); echo nl2br("Decryption of: " . $file . '.aes' . "\n"); // read content $data = file_get_contents($file . '.aes'); // decrypt and write to a new file (existing file is overwritten) file_put_contents($file . '.aes' . '.decrypted', $crypt->decrypt($data)); echo nl2br("AES-file decryption finished" . "\n"); echo nl2br("============================" . "\n");