[PHP]实现AES-256-CBC和HMAC_SHA512加密

    /**
    * 对传入参数进行AES-256-CBC和HMAC-SHA512加密
    *
    * @param string $data 需要加密的字段
    * @since 1.0 
    * @return array        urlencode后的加密字段
    */
    private function encryption($data, $aesKey, $shaKey){
        $msgData = @openssl_encrypt ($data, "AES-256-CBC", $aesKey);
        $dataDigest = hash_hmac("sha512", $msgData, base64_encode($shaKey));
        return array($msgData, $dataDigest);
    }

你可能感兴趣的:(PHP)