PHP Classes
Icontem

File: _classes/SHA1.class.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Marius Zadara  >  Message Digest  >  _classes/SHA1.class.php  
File: _classes/SHA1.class.php
Role: Class source
Content type: text/plain
Description: SHA1 hash algorithm
Class: Message Digest
Generate message digests with hashing algorithms
 

Contents

Class file image Download
<?php

/**
 * SHA1 hasher implementation.
 * 
 * @author Marius Zadara <marius@zadara.org>
 * @category org.zadara.marius.messagedigester.classes 
 * @copyright (C) 2008, Marius Zadara <marius@zadara.org>
 * @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);
    }
}


?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products