Hash PHP Generator

Discussion in 'PHP' started by lomerok, 7 Jun 2008.

  1. lomerok

    lomerok Elder - Старейшина

    Joined:
    23 Apr 2008
    Messages:
    140
    Likes Received:
    8
    Reputations:
    0
    вот скрипт который записывает сгенериный Хэш в файл ...
    PHP:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=cp1251" />
    </head>
    <body>
    <form method="GET">
    Введите MD5 хэш :
    <input type="text" name="hash">
    <input type="submit" value="OK">
    </form>
    <?
      
    global $hash2;
    //$hash=isset($_GET['hash']) ? $_GET['hash'] : '';  
    //----------------Get Hash-------------------------------------------------------------------
     
    function gethash($hash)
     {
      global 
    $hash2;
      
    $f="test.txt";  
      
    $file=file_get_contents($f); 
      
    preg_match("/(^|\n){$hash}:(\S+)/s",$file,$m); 
      if(isset(
    $m[0]))
      {
    $hash2=$m[0];print "ok";}
     }
    //---------------Random Hash---------------------------------------------------------------
    function random($max
    {
     
    $chars="12";  
     
    $size=StrLen($chars)-1;  
     
    $password=null;

      while(
    $max--)
      { 
       
    $password.=$chars[rand(0,$size)]; 
      }
      
    $hash1="\n".md5($password).":$password";
      
    gethash(md5($password));
      print 
    "<br>hash1=$hash1";
      print 
    "<br>hash2=$hash2";
      if(
    $hash1==$hash2) {print "<br>Существует !!!";}
      else
       {
        print 
    "<br>Записано !!!";
        
    $file="test.txt";
        
    $fo=fopen($file,"a+");
        
    fwrite($fo,$hash1);
        
    fclose($fo);
       }

    $i=0;

    while(
    $i<5)
    {
     
    random(2);
     print 
    "<br><hr>";
     
    $i++;
    }
    ?>
    </body>
    </html>
    неработает $hash2 в функции random при вызове gethash(md5($password)). почему ??
     
    #1 lomerok, 7 Jun 2008
    Last edited: 7 Jun 2008
  2. BlackSun

    BlackSun Banned

    Joined:
    1 Apr 2007
    Messages:
    989
    Likes Received:
    1,168
    Reputations:
    446
    for ($i=0; $i<50; $i++)
    {
    .....
     
  3. Chaak

    Chaak Elder - Старейшина

    Joined:
    1 Jun 2008
    Messages:
    1,059
    Likes Received:
    1,067
    Reputations:
    80
    Очень полезный скрипт от товарисча I-I()/Ib
    PHP:
    <?php 
    $hash
    =array(array('md3, md4 hmac, md5, md5 hmac, ripmed 128, NTHash, LM, MacroHash','/^[a-zA-Z0-9]{32}$/'), 
                array(
    'md4 base64, md5 base64,','/^[a-zA-Z0-9\/\+]{22}\=\=[a-zA-Z0-9\/]{3}\=$/'), 
                array(
    'md5 Unix,','/^\$\d\$[\D\d]*\$[a-zA-Z0-9\.\/]{22}$/'), 
                array(
    'md5 APR,','/^\$apr1\$[\D\d]*\$[a-zA-Z0-9\.\/]{22}$/'), 
                array(
    'mysql,','/^[a-zA-Z0-9]{16}$/'), 
                array(
    'sha-1 base64,','/^[a-zA-Z0-9\/\+\=]{28}$/'), 
                array(
    'mysql5, sha-1, sha-1 hmac, ripmed 160,','/^[a-zA-Z0-9]{40}$/'), 
                array(
    'sha-256, ГОСТ Р34.11-94, ripmed 256,','/^[a-zA-Z0-9]{64}$/'), 
                array(
    'ripmed 320,','/^[a-zA-Z0-9]{80}$/'), 
                array(
    'sha-384,','/^[a-zA-Z0-9]{98}$/'), 
                array(
    'crc16, crc16-ccitt,','/^[a-zA-Z0-9]{4}$/'), 
                array(
    'crc32, crc32b, GHash-32, Adler32','/^[a-zA-Z0-9]{8}$/'), 
                array(
    'sha-512,','/^[a-zA-Z0-9]{128}$/')); 
    if(!empty(
    $_POST['hash1'])){ 
        
    $hashstr=''
        for(
    $i=0;$i<count($hash);$i++){ 
            if(
    preg_match($hash[$i]['1'],$_POST['hash1']))$hashstr.=$hash[$i]['0']; 
        } 
        if(!empty(
    $hashstr))echo('Это похоже на '.$hashstr.' <hr>'); 
        else echo(
    'Это что то хитрое o_O<hr>'); 

    echo(
    '<form method="post"> 
    <input type="text" name="hash1" value=""><input type="submit" value="прочекать"> 
    </form>'
    ); 
    ?>
    Советую часть кода прикрутить...
     
  4. lomerok

    lomerok Elder - Старейшина

    Joined:
    23 Apr 2008
    Messages:
    140
    Likes Received:
    8
    Reputations:
    0
    разобрался , роботает
     
  5. schwarze

    schwarze Member

    Joined:
    1 Dec 2008
    Messages:
    64
    Likes Received:
    38
    Reputations:
    5
    У кого-нить есть исходники hash функции получения MySQL OLD_PASSWORD ?