I’m writing a Perl script that needs to connect to a SMTP server in order to send a mail, but I really don’t like this kind of things :
my $pass = '123456';
And I found Data::Encrypted, that should allow the user to prompt it the first time and then store it encrypted.
use Data::Encrypted file => ".passwd", qw(encrypted);
my $password = encrypted('password');
But I cannot make it work, it makes a running time error :
Bad key file format at /Library/Perl/5.12/Data/Encrypted.pm line 78
Is anybody having the same issue, or know another way to hide/protect password?
The Data::Encrypted module was last released in 2001. I’d say that’s a good sign not to use it.
Normally, I’d say storing passwords at all is a bad idea even encrypted. However, if you must store a password for use contacting another system, encrypting it is the way to go. The way I would do it is something like this:
For more information see Crypt::Rijndael and IO::Prompter.