> 4 & 0xf) + ord('a'); $str .= chr($ch); $ch = ($tmpValue & 0xf) + ord('a'); $str .= chr($ch); } return $str; } /** * 加密数据 * @param String $encryptedText 待加密密文 * @return String */ public static function encrypt(string $encryptedText) { $ciphertext = openssl_encrypt($encryptedText, "AES-128-CBC", self::SECRET_KEY, OPENSSL_RAW_DATA, self::IV); return self::encodeBytes($ciphertext); } /** * 解密数据 * @param String $encryptedText 待解密数据 * @return String */ public static function decrypt(string $encryptedText) { $encryptedText = self::decodeBytes($encryptedText); return openssl_decrypt($encryptedText, "AES-128-CBC", self::SECRET_KEY, OPENSSL_RAW_DATA, self::IV); } }