Location: PHPKode > scripts > Message Digest > message-digest/index.php
<?php

/**
 * Message digest testing unit.
 * This unit will test the message digester functionality.
 * 
 * @author Marius Zadara <hide@address.com>
 * @copyright (C) 2008, Marius Zadara <hide@address.com>
 * @license GNU GPL
 * @package org.zadara.marius.messagedigester
 *
 * @tutorial 
 * 	$md = new MessageDigest();
 * 	$md->getInstance("<HASH ALGORITHM>");
 * 	$md->update("<TEXT TO DIGEST>");
 *  echo $md->digest();
 */


// add all the file required by the application
require '_interfaces/addInterfaces.php';
require '_exceptions/addExceptions.php';
require '_classes/addClasses.php';


// catch any exceptions
try
{
	// instanciate the message digest class
	$md = new MessageDigest();
	
	// set the hash agorithm
	$md->getInstance("MD5");
	
	// set the text to digest
	$md->update("Hello World");
	
	// display the digested text 
	echo $md->digest();
}
catch (MessageDigestException $me)
{
	// display the message of the digester exception
	echo $me->getMessage();
}
catch (Exception  $exception)
{
	// display the message of the general exception
	echo $exception->getMessage();
}

?>
Return current item: Message Digest