部署仓库初始化:epay 部署配置、补丁与插件
- docker-compose.prod.yml:挂载 epay-ui.css/js/head.php 补丁到 staging(镜像升级不丢) - docker/nginx.conf:补丁静态资源 no-cache,改版立即生效 - patches/: - test.php 修复 paytype JSON 对象导致测试支付页空白 - epay-ui.css 后台全屏/侧栏加宽/导航两列布局覆盖 - epay-ui.js 去除页面容器宽度限制 + 侧栏当前菜单自动滚动 - head.php 资源 ?v= 版本号强制回源 - functions.php is_public_url 白名单等既有补丁 - plugins/ 支付插件源码 - .gitignore 排除 .env 等敏感与临时文件
This commit is contained in:
commit
b7613ba082
176 files changed
+47057
No files matched your search
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
class DES3 {
|
||||
|
||||
// 数据加密
|
||||
function encrypt($input, $key) {
|
||||
// 使用 OpenSSL 3DES-CBC 加密
|
||||
$key = str_pad($key, 24, '0'); // 确保密钥长度为 24 字节
|
||||
$iv = openssl_random_pseudo_bytes(8); // 3DES 的 IV 长度为 8 字节
|
||||
$input = $this->pkcs5_pad($input, 8); // 3DES 块大小为 8 字节
|
||||
$encrypted = openssl_encrypt(
|
||||
$input,
|
||||
'des-ede3-cbc', // 3DES-CBC 模式
|
||||
$key,
|
||||
OPENSSL_RAW_DATA,
|
||||
$iv
|
||||
);
|
||||
return base64_encode($iv . $encrypted); // 返回 IV + 加密数据
|
||||
}
|
||||
|
||||
// 数据解密
|
||||
function decrypt($encrypted, $key) {
|
||||
$encrypted = base64_decode($encrypted);
|
||||
$key = str_pad($key, 24, '0'); // 确保密钥长度为 24 字节
|
||||
$iv = substr($encrypted, 0, 8); // 提取前 8 字节作为 IV
|
||||
$encrypted = substr($encrypted, 8); // 剩余部分为加密数据
|
||||
$decrypted = openssl_decrypt(
|
||||
$encrypted,
|
||||
'des-ede3-cbc', // 3DES-CBC 模式
|
||||
$key,
|
||||
OPENSSL_RAW_DATA,
|
||||
$iv
|
||||
);
|
||||
return $this->pkcs5_unpad($decrypted); // 去除填充
|
||||
}
|
||||
|
||||
// PKCS5 填充
|
||||
function pkcs5_pad($text, $blocksize) {
|
||||
$pad = $blocksize - (strlen($text) % $blocksize);
|
||||
return $text . str_repeat(chr($pad), $pad);
|
||||
}
|
||||
|
||||
// PKCS5 去除填充
|
||||
function pkcs5_unpad($text) {
|
||||
$pad = ord($text[strlen($text) - 1]);
|
||||
if ($pad > strlen($text)) {
|
||||
return false;
|
||||
}
|
||||
if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) {
|
||||
return false;
|
||||
}
|
||||
return substr($text, 0, -1 * $pad);
|
||||
}
|
||||
|
||||
function encrypt2($input, $key)
|
||||
{
|
||||
$key = str_pad($key, 24, '0');
|
||||
$encrypted = openssl_encrypt($input, 'des-ede3', $key, OPENSSL_RAW_DATA);
|
||||
return base64_encode($encrypted);
|
||||
}
|
||||
|
||||
function decrypt2($encrypted, $key)
|
||||
{
|
||||
$key = str_pad($key, 24, '0');
|
||||
$encrypted = base64_decode($encrypted);
|
||||
$decrypted = openssl_decrypt($encrypted, 'des-ede3', $key, OPENSSL_RAW_DATA);
|
||||
return $decrypted;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in new issue
Block a user