<?php
ini_set('date.timezone','Asia/Shanghai');
class AES {
public $localIV;
public $encryptKey;
public function encrypt($str) {
return openssl_encrypt($str, 'AES-256-CFB', $this->encryptKey, 0, $this->localIV);
}
public function decrypt($str) {
return openssl_decrypt($str, 'AES-256-CFB', $this->encryptKey, 0, $this->localIV);
}
}
$aes = new AES();
$aes->encryptKey = md5('AMIGK97730'); //修改类属性变量
$aes->localIV = substr(md5($aes->encryptKey), 0, 16); //修改类属性变量
echo "客户端已开始运行,您可以直接输入消息内容来发送。\n";
var_dump($aes->encryptKey);
var_dump($aes->localIV);
$message = "Windows Support
Yes !! Windows support is offered thanks to the pthread-w32 library.
Releases for Windows can be found: http://windows.php.net/downloads/pecl/releases/pthreads/
Simple Windows Installation
Add pthreadVC2.dll (included with the Windows releases) to the same directory as php.exe eg. C:\xampp\php
Add php_pthreads.dll to PHP extension folder eg. C:\xampp\php\ext";
$en_text = $aes->encrypt(json_encode([$message]));
var_dump($en_text);
$de_text = json_decode($aes->decrypt($en_text), true);
var_dump($de_text);