* @version : HUOSDK 9.0 */ namespace huoIdentify\controller; class AesEcb { /** * key * * @var string */ private $key; /** * method * * @var string */ private $cipher; /** * iv length * * @var int */ private $ivlen; /** * AES constructor. * * @param $key * @param string $cipher */ public function __construct($key, $cipher = 'aes-128-ecb') { $this->cipher = $cipher; $this->key = $key; } /** * * @param $cipherText * * @return string|false */ public function decrypt($cipherText) { return openssl_decrypt($cipherText, $this->cipher, $this->key, OPENSSL_RAW_DATA); } /** * * @param string $plainText * * @return string */ public function encrypt($plainText) { $result = openssl_encrypt($plainText, $this->cipher, $this->key, OPENSSL_RAW_DATA); return bin2hex($result); } }