<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; class SecureUtil { const DEFAULT_CIPHER_ALGO = 'aes-256-cbc'; const MODE_DEFAULT = 'default'; const MODE_SALTED = 'salted'; public static function aesEncode($jPfeB, $CnWtd, $Uy3ye = false, $bJtEU = 'default') { goto ScINo; ScINo: $XGeOO = $jPfeB; goto OFZ81; H0k3o: switch ($bJtEU) { case self::MODE_SALTED: goto mdKM8; j1RtZ: $XI2ue = openssl_random_pseudo_bytes(8); goto apf_1; XRQoU: $jPfeB = substr($psHHp, 0, 32); goto t9hUv; ZiaZB: return base64_encode('Salted__' . $XI2ue . $MRhmS); goto DpvWc; apf_1: $psHHp = self::evpBytesToKey($XI2ue, $jPfeB); goto XRQoU; mdKM8: $fSCUf = 'AES-256-CBC'; goto j1RtZ; t9hUv: $ncbe9 = substr($psHHp, 32, 16); goto Udbfv; Udbfv: $MRhmS = openssl_encrypt(urlencode($CnWtd), $fSCUf, $jPfeB, OPENSSL_RAW_DATA, $ncbe9); goto ZiaZB; DpvWc: default: goto mVcyS; pDWGm: $ncbe9 = openssl_random_pseudo_bytes($j0fvf); goto fW3VD; mVcyS: $j0fvf = openssl_cipher_iv_length(self::DEFAULT_CIPHER_ALGO); goto pDWGm; y3SKm: return base64_encode($b0poM . '::' . $ncbe9); goto s2C39; fW3VD: $b0poM = openssl_encrypt($CnWtd, self::DEFAULT_CIPHER_ALGO, $XGeOO, 0, $ncbe9); goto y3SKm; s2C39: } goto n53XS; OFZ81: if ($Uy3ye) { $XGeOO = base64_decode($XGeOO); } goto H0k3o; n53XS: } public static function aesDecode($jPfeB, $CnWtd, $Uy3ye = false) { goto rOWOo; yVwGU: list($j3sPz, $ncbe9) = explode('::', $CnWtd, 2); goto pomx9; pomx9: return openssl_decrypt($j3sPz, self::DEFAULT_CIPHER_ALGO, $XGeOO, 0, $ncbe9); goto sA6CH; sLXk2: if (strpos($CnWtd, 'Salted__') === 0) { goto OL0xr; Mg2w2: $ncbe9 = substr($psHHp, 32, 16); goto uytZr; i5RT0: $jPfeB = substr($psHHp, 0, 32); goto Mg2w2; uytZr: $j3sPz = urldecode(openssl_decrypt($MRhmS, self::DEFAULT_CIPHER_ALGO, $jPfeB, OPENSSL_RAW_DATA, $ncbe9)); goto sJDKH; wOcnf: $psHHp = self::evpBytesToKey($XI2ue, $jPfeB); goto i5RT0; OL0xr: $XI2ue = substr($CnWtd, 8, 8); goto AV5Cn; AV5Cn: $MRhmS = substr($CnWtd, 16); goto wOcnf; sJDKH: return $j3sPz; goto qu8aq; qu8aq: } goto yVwGU; FCrxc: if ($Uy3ye) { $XGeOO = base64_decode($XGeOO); } goto tIj28; rOWOo: $XGeOO = $jPfeB; goto FCrxc; tIj28: $CnWtd = base64_decode($CnWtd); goto sLXk2; sA6CH: } private static function evpBytesToKey($XI2ue, $Oedtb) { goto DiqnJ; gS8YG: return $ybbl4; goto j1unR; Htg8K: while (strlen($ybbl4) < 48) { $k8Xle = hash('md5', $k8Xle . $Oedtb . $XI2ue, true); $ybbl4 .= $k8Xle; } goto gS8YG; HgJHD: $k8Xle = ''; goto Htg8K; DiqnJ: $ybbl4 = ''; goto HgJHD; j1unR: } public static function encryptKey() { return modstart_config('EncryptKey', 'mock-encrypt-key-random-string--'); } }