Location: PHPKode > scripts > Message Digest > message-digest/_classes/SHA1.class.php
<?php

/**
 * SHA1 hasher implementation.
 * 
 * @author Marius Zadara <hide@address.com>
 * @category org.zadara.marius.messagedigester.classes 
 * @copyright (C) 2008, Marius Zadara <hide@address.com>
 * @license GNU GPL
 * @package org.zadara.marius.messagedigester
 * 
 * @final
 * @see IHashAlgorithm
 */
final class SHA1 implements IHashAlgorithm 
{
	/**
	 * Hash function implementation.
	 *
	 * @param string $string The text to hash
	 * @param boolean $raw_output Raw output
	 * @return string The hash of the text
	 * @static 
	 */	
	public static function hash($string, $raw_output = false)
	{
		// validate the length of the string		
		if (strlen($string) == 0)
			throw new HashAlgorithmException("Empty string to hash.");

		// set the correct raw ouput			
		if (($raw_output !== false) && ($raw_output !== true))
			$raw_output = false;	
		
		// base function call		
		return sha1($string, $raw_output);
	}
}


?>
Return current item: Message Digest