Getting Differnt results from hasing the same string. Help Needed

Discussion in 'PHP' started by redslazers, Jun 4, 2011.

  1. #1
    If i run the following i should be getting the same hash but for some reason they come out different.
    
    $salt="553099";
    $pass = "computer";
    $password = "computer";
    $pass  = sha1('$salt . $pass');
    $pass2 = sha1('$salt . $password');
    
    print $pass;
    print "<br/>";
    print $pass2;
    
    PHP:
    It prints
    15a53d55ae2af4db3843aa8700729c2332626859
    fd78226853ad10dcac53b55748983d1ccf31ffc1
    HTML:
    Any explanation is appreciated
     
    redslazers, Jun 4, 2011 IP
  2. IAreOwn

    IAreOwn Active Member

    Messages:
    46
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    95
    #2
    because you're doing it wrong, what happen is instead of 553099computer that should be pass to the sha1 function your actually passing '$salt . $pass' and '$salt . $password' just remove the single quotes..
     
    IAreOwn, Jun 4, 2011 IP
  3. redslazers

    redslazers Peon

    Messages:
    242
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks :) that solved it
     
    redslazers, Jun 4, 2011 IP