(PHP Extension) HMAC with SHA256
Demonstrates how to compute a HMAC SHA256 keyed-hash message authentication code.
<?php
// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$crypt = new CkCrypt2();
// The output will be Hex, so set the EncodingMode:
$crypt->put_EncodingMode('hex');
// Set the hash algorithm:
// Choices are: md5, sha-1, sha256, sha384, sha512, md2, haval
$crypt->put_HashAlgorithm('sha256');
// Set the HMAC key:
$crypt->SetHmacKeyEncoded('The_API_Secret','ascii');
$mac = $crypt->hmacStringENC('The quick brown fox jumps over the lazy dog');
print $mac . "\n";
?>
|