jhehnle / picencrypter
使用这个简单的PHP脚本,您可以加密和解密图片。
dev-main
2022-04-04 19:54 UTC
This package is auto-updated.
Last update: 2024-09-05 00:47:35 UTC
README
嘿!这是一个简单且单一的PHP图片解密器加密器。图片使用openssl进行解密和加密,因此提供了各种加密选项。
使用composer的使用方法
只需运行composer require jhehnle/picencrypter
。然后,您只需包含自动加载器。
// autoload with composer
require_once __DIR__ . '/vendor/autoload.php';
$decrypter = new \jhehnle\picencrypter\picencrypter;
// set the public and private key
$decrypter->public_key = 'user:date';
$decrypter->secret_key = 'mysafeprivatekey';
// encrypt a picture
$decrypter->encode_decode("https://twc-media.de/assets/img/logo.png", 'encrypt');
// decrypt a picture
$decrypter->encode_decode("RFVzOXhWVUdKRVpyNUZyRCtFY...", 'decrypt');
不使用composer的使用方法
如果您想在项目中使用此脚本而不使用composer,只需将项目复制到您的项目中,并包含src/jhehnle/picencrypter.php
。
// use without composer
include 'src/jhehnle/picencrypter.php';
将加密图片保存到文件中
// encrypt a picture
$decrypter->encode_decode("https://twc-media.de/assets/img/logo.png", 'encrypt');
$decrypter->output = 'file';
此功能将加密图片保存为具有唯一名称的文件。
使用另一个openssl算法
// change openssl algorithm
$decrypter->algo = 'AES-256-CBC';
您可以使用任何openssl兼容的算法。您可以使用PHP中的openssl_get_cipher_methods
函数获取完整列表。
解密图片并仅显示Base64格式
// decrypt a encrypted picture
$decrypter->encode_decode("RFVzOXhWVUdKRVpyNUZyRCtFY...", 'decrypt');
$decrypter->output = 'str';
这返回的不是图片,而是Base64字符串。
版本
v1.2.1
许可证
本项目采用Apache License 2.0许可证。请参阅LICENSE以获取更多信息。