PHP code example of davidnineroc / encrypt
1. Go to this page and download the library: Download davidnineroc/encrypt 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/ */
davidnineroc / encrypt example snippets
/ 位图文件的路径(原始的或者加密过的都是构造参数)
$bmpPath = __DIR__.'/data/gps.bmp';
try {
$encrypt = new \DavidNineRoc\Encrypt\Handler($bmpPath);
// 1. 加密文件
// 2. 返回一个 FileStream 对象
$encryptFile = __DIR__.'/data/gps.txt';
$fileStream = $encrypt->encrypt($encryptFile);
// 解密返回一个 FileStream 对象
$fileStream = $encrypt->decrypt();
// 获取文件名
// 获取文件数据
$fileStream->getName();
$fileStream->getData();
// 如需保存
file_put_contents($fileStream->getName(), $fileStream->getData());
} catch (Exception $e) {
echo $e->getMessage();
}