Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Re: Re: Ecrypting passwords

by hardburn (Abbot)
on Nov 05, 2003 at 18:40 UTC ( [id://304820]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://304820]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2024-04-23 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found