lyoshenka/php-hmac
Composer 安装命令:
composer require lyoshenka/php-hmac
包简介
A generic HMAC function that can be used with any hash
README 文档
README
A generic HMAC function that can be used with any hash
Install
composer install lyoshenka/php-hmac
Use
<?php
require __DIR__.'/vendor/autoload.php';
# Ensure that your hash functions returns raw output (not hex)
$sha256Fn = function($message) { return hash('sha256', $message, true); };
# Look up the block size - https://en.wikipedia.org/wiki/Comparison_of_cryptographic_hash_functions
$blockSize = 64; // make sure this in bytes, not bits
# Compute the HMAC digest
$digest = \lyoshenka\hmac("The message text goes here", "secret-key", $sha256Fn, $blockSize);
# Output the digest as a hex string
echo bin2hex($digest) . "\n";
Examples
See examples.php
References
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-29