Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Making keys for Crypt::Blowfish?

by athomason (Curate)
on Aug 20, 2000 at 23:47 UTC ( [id://28738]=note: print w/replies, xml ) Need Help??


in reply to Making keys for Crypt::Blowfish?

Looking at the pod, Crypt::Blowfish takes any random string up to 56 bytes (i.e. 448 bits) long for its key, e.g. my $key = pack("H16", "0123456789ABCDEF"); All you need to do is string together 56 random bytes. What you're really after is a true random number generator, because the default rand is insufficient for cryptographic purposes. If you're on a Unix system with a decent /dev/random device (look at your system docs), you can use the Crypt::Random module:
use Crypt::Random qw( makerandom ); my $r = makerandom ( Size => 448, Strength => 1 );
Another alternative which isn't quite as easy to use for cryptography is Math::TrulyRandom, but it's slow (though one 56-byte key won't kill you, certainly). There's some discussion here regarding cryptography and random numbers as well.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (None)
    As of 2024-04-25 01:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found