Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Re: Passing data from one script to another

by Anonymous Monk
on May 02, 2003 at 15:57 UTC ( [id://255052]=note: print w/replies, xml ) Need Help??


in reply to Re: Passing data from one script to another
in thread Passing data from one script to another

I have just taken a look at Digest:MD5 and it looks fairly simple to use _if you know how_. How would i pass somethign like $password containing a plain text password thru Digest:MD5 and output the encrypted password as $encr_pass?.
  • Comment on Re: Re: Passing data from one script to another

Replies are listed 'Best First'.
Re: Re: Re: Passing data from one script to another
by hardburn (Abbot) on May 02, 2003 at 16:09 UTC

    Like this:

    use Digest::MD5 qw(md5); my $password = "passwd"; my $encr_pass = md5($password);

    But for anything new, you should be using SHA1 (as MD5 is quite possibly on its deathbed as far as security applications go), which is done like this:

    use Digest::SHA1 qw(sha1); my $password = "passwd"; my $encr_pass = sha1($password);

    Unfortunately, Digest::SHA1 doesn't come with Perl by default (the MD5 module does).

    Better still, you can use simply Digest with an OO interface to specify the hash algorithm at runtime. IMHO, its important to be able to switch from one crypto/hash algorithm to another on a moment's notice, in case your current algorithm turns out to have a catastrophic security hole. The Digest.pm module helps you to do that change. Here's how to use it:

    use Digest; my $password = "passwd"; my $digest = Digest->new("SHA1"); $digest->add($password); my $encr_pass = $digest->digest();

    The OO interface in the Digest.pm module is basically the same as the interface in the Digest::MD5 and Digest::SHA1 modules (I used the functional interface for those modules above, for simplicity's sake).

    ----
    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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-19 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found