<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use ModStart\Core\Exception\BizException; class SecureUtil { const DEFAULT_CIPHER_ALGO = 'aes-256-cbc'; const MODE_DEFAULT = 'default'; const MODE_SALTED = 'salted'; public static function aesEncode($l6tBV, $zvN10, $iG6ow = false, $qAUbs = 'default') { goto czz5f; NGdq9: switch ($qAUbs) { case self::MODE_SALTED: goto g6Har; PDZQB: $V88mV = substr($Ol6yA, 32, 16); goto Q6mOt; kgPof: $l6tBV = substr($Ol6yA, 0, 32); goto PDZQB; VNEJs: $Ol6yA = self::evpBytesToKey($twJcY, $l6tBV); goto kgPof; F9C3h: $twJcY = openssl_random_pseudo_bytes(8); goto VNEJs; RjBUI: return base64_encode('Salted__' . $twJcY . $HvreM); goto arJUR; g6Har: $pK00s = 'AES-256-CBC'; goto F9C3h; Q6mOt: $HvreM = openssl_encrypt(urlencode($zvN10), $pK00s, $l6tBV, OPENSSL_RAW_DATA, $V88mV); goto RjBUI; arJUR: default: goto s8pmx; N74Fp: return base64_encode($a3kQE . '::' . $V88mV); goto mexLQ; HjLZm: $a3kQE = openssl_encrypt($zvN10, self::DEFAULT_CIPHER_ALGO, $Sz1ru, 0, $V88mV); goto N74Fp; s8pmx: $tV3mM = openssl_cipher_iv_length(self::DEFAULT_CIPHER_ALGO); goto xl9Os; xl9Os: $V88mV = openssl_random_pseudo_bytes($tV3mM); goto HjLZm; mexLQ: } goto GVahZ; czz5f: $Sz1ru = $l6tBV; goto FMSDy; FMSDy: if ($iG6ow) { $Sz1ru = base64_decode($Sz1ru); } goto NGdq9; GVahZ: } public static function aesDecode($l6tBV, $zvN10, $iG6ow = false) { goto R_DFm; D05ov: return openssl_decrypt($A0Fxg, self::DEFAULT_CIPHER_ALGO, $Sz1ru, 0, $V88mV); goto rXBp0; p3Nic: $Sz1ru = $l6tBV; goto YguU1; ZcywQ: if (strpos($zvN10, 'Salted__') === 0) { goto MU28s; O5cTH: $HvreM = substr($zvN10, 16); goto WqyvT; QN6Kt: $l6tBV = substr($Ol6yA, 0, 32); goto jdDcV; MU28s: $twJcY = substr($zvN10, 8, 8); goto O5cTH; WqyvT: $Ol6yA = self::evpBytesToKey($twJcY, $l6tBV); goto QN6Kt; jdDcV: $V88mV = substr($Ol6yA, 32, 16); goto tEYbr; tEYbr: $A0Fxg = urldecode(openssl_decrypt($HvreM, self::DEFAULT_CIPHER_ALGO, $l6tBV, OPENSSL_RAW_DATA, $V88mV)); goto mrhAp; mrhAp: return $A0Fxg; goto vmCWp; vmCWp: } goto JLLG1; JLLG1: list($A0Fxg, $V88mV) = explode('::', $zvN10, 2); goto D05ov; fUK22: $zvN10 = base64_decode($zvN10); goto ZcywQ; YguU1: if ($iG6ow) { $Sz1ru = base64_decode($Sz1ru); } goto fUK22; R_DFm: BizException::throwsIfEmpty('SecureUtil.Key Empty', $l6tBV); goto p3Nic; rXBp0: } private static function evpBytesToKey($twJcY, $V3jYa) { goto tnDAW; wu3Zn: return $B5Nps; goto yJ4mU; tnDAW: $B5Nps = ''; goto LTf7j; LTf7j: $JUm5r = ''; goto KT7q1; KT7q1: while (strlen($B5Nps) < 48) { $JUm5r = hash('md5', $JUm5r . $V3jYa . $twJcY, true); $B5Nps .= $JUm5r; } goto wu3Zn; yJ4mU: } public static function encryptKey() { return config('env.ENCRYPT_KEY'); } }