Sample code for 30+ languages & platforms
PHP Extension Requires Chilkat v11.0.0+

Workaround for the deprecated Crypt2.HashString method

Shows how to replace the deprecated HashString method. (Chilkat is moving away from the use of CkByteData.)

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$crypt = new CkCrypt2();

$crypt->put_Charset('utf-8');

$crypt->put_HashAlgorithm('sha256');

$inputStr = 'This is a test.';

//  ------------------------------------------------------------------------
//  The HashString method is deprecated:

$outData = new CkByteData();

$success = $crypt->HashString($inputStr,$outData);

//  ------------------------------------------------------------------------
//  Workaround.
//  (Chilkat is moving away from using CkByteData)

$crypt->put_EncodingMode('base64');
$hash_base64 = $crypt->hashStringENC($inputStr);

print $hash_base64 . "\n";

?>