Location: PHPKode > scripts > Extended MD5 > extended-md5/emd5.class.php
<?php
        /*-----------------------------------------------------------------------------

    eMD5 0.11 BETA
    Extended MD5

    Author: W. Paulisse aka Chronos
    Last Modified: 29-1-2005 19:05

    Concept: Embed a user-defined code onto a md5 hash using binary xor algoritmes

    changelog:
      0.10
        - The creation!
      0.11
        - Added a twist algorimtme for additonal embedding
        - Converted to a single function supported by a CLASS
        - added a check for EMD5_CODE Constant


    Bugs: None

    Todo:
      - Script tuning
      - Stress test / performance

        ------------------------------------------------------------------------------*/

  define("EMD5_CODE","SecretCodeHere"); //Your eMD5 server-side code

  function emd5($str_in){return EMD5::hash($str_in);}
  class EMD5 {
    function BinaryString($strStr){$i=0;while($i < strlen($strStr)){$NewStr .= "+". str_pad(decbin(ord(substr($strStr,$i++,1))), 8, "0", STR_PAD_LEFT);}return $NewStr;}
    function BinairXorValidator($str1,$str2){ if($str1 != "+" && $str2 != "+"){ if($str1 xor $str2){ return "1"; }else{ return "0"; } }else{ return "+"; } }
    function hash($str_in){
      if(!defined("EMD5_CODE")){exit("<b>error: </b> emd5_code is not defined");}
      $str = trim($str_in);$srv = md5(EMD5_CODE);$str = md5($str);
      $i=0;while($i != 32){$arr_str[] = substr($str,$i,8);$i=$i+8;}
      $i=0;while($i != 32){$arr_srv[] = substr($srv,$i,8);$i=$i+8;}
      $str1 = EMD5::BinaryString($arr_srv[0].$arr_str[1].$arr_srv[2].$arr_str[3]);
      $str2 = EMD5::BinaryString($arr_str[0].$arr_srv[1].$arr_str[2].$arr_srv[3]);
      while($e < strlen($str1)){ $str_combined .= EMD5::BinairXorValidator(substr($str1,$e,1),substr($str2,$e,1)); $e++; }
      $str_out = md5($str_combined);
      return $str_out;
    }
  }
?>
Return current item: Extended MD5