PHP Classes

File: _classes/MD5.class.php

Recommend this page to a friend!
  Classes of Marius Zadara   Message Digest   _classes/MD5.class.php   Download  
File: _classes/MD5.class.php
Role: Class source
Content type: text/plain
Description: MD5 hash algorthm
Class: Message Digest
Generate message digests with hashing algorithms
Author: By
Last change:
Date: 15 years ago
Size: 960 bytes
 

Contents

Class file image Download
<?php

/**
 * MD5 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 MD5 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 md5($string, $raw_output);
    }
}


?>