http://qs321.pair.com?node_id=304820


in reply to Re: Re: Re: Ecrypting passwords
in thread Ecrypting passwords

I suspect there is somehow a bug in how you're getting the data from the web. Try printing out the hex encoding of the orginal string before you send it to the hash function to make sure you're putting in the exact same data each time.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Ecrypting passwords
by neilwatson (Priest) on Nov 05, 2003 at 18:46 UTC
    Even if I hard code them:
    # encrypts password using # SHA-1 algorithm my $sha1 = Digest::SHA1->new; # reset algorithm $sha1->hexdigest; # encrypt $passwd = 'password'; $salt = 1658087940; my $secret = $sha1->sha1_hex($passwd . $salt);

    The hash is still different each time.

    Neil Watson
    watson-wilson.ca

      Sorry, there is something screwy with your system. Getting the exact same hash value for the exact same data is a design goal of any hash algorithm worth using.

      This is what I get on your code:

      $ cat test.pl #!/usr/local/bin/perl use Digest::SHA1; # encrypts password using # SHA-1 algorithm my $sha1 = Digest::SHA1->new; # reset algorithm $sha1->hexdigest; # encrypt $passwd = 'password'; $salt = 1658087940; my $secret = $sha1->sha1_hex($passwd . $salt); print "Secret: ", $secret, "\n"; $ ./test.pl Secret: c757584a6cff45409cdf716903aa363e95354860 $ ./test.pl Secret: c757584a6cff45409cdf716903aa363e95354860

      ----
      I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
      -- Schemer

      : () { :|:& };:

      Note: All code is untested, unless otherwise stated

        It's definitely a mason or mod_perl issue. The same thing happens on another server. I also tried the code as CGI script and it worked normally (hashes were the same each time).

        I will ask the mason group.

        Neil Watson
        watson-wilson.ca