c-squared-solutions-llc/hmac-util
Composer 安装命令:
composer require c-squared-solutions-llc/hmac-util
包简介
PHP HMAC utility library for signing and verifying signed requests
README 文档
README
Hmac Util currently supports signing requests with an hmac signature. You will need to provide the following to the library.
- HMAC Credentials (Username, Secret)
- HMAC Algorithm you would like to use
- Request Line (see HTTP REQUEST STANDARDS https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html)
- Body of the request (if any)
- Headers you wish to sign with (do not include headers you are sending but do not want as part of signature)
Example of use below
<?php
$hmac_request = new CSquaredSolutionsLlc\HmacUtil\HmacRequest();
$hmac_request->setAlgorithm('sha256');
$hmac_request->setCreds("testing","testing");
$hmac_request->request_line = 'POST /test HTTP/1.1';
$hmac_request->body = '{test: 1}';
$hmac_request->headers = [
'Content-Type' => 'application/json',
'Content-Length' => 115252
];
$hmac_util = new CSquaredSolutionsLlc\HmacUtil\HmacUtil();
$hmac_request = $hmac_util->sign($hmac_request);
After you get the HmacRequest object back, it will contain an authorization header and possibly two more headers for the signature. Send all headers, plus any others you want, and the body from the HmacRequest object via any restful library that supports it.
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-15