Password Manager v0.3
by matt
Here’s something I’m pretty proud of. A couple months ago I started playing with Perl again and I wrote this very simple, command-line password manager. I now use it regularly to retrieve and update my passwords.
So simple, but so helpful. Thank you, Larry Wall.
# This is Password Manager v0.3 # # A program written by and for # Matt Forsythe. It will store # passwords in a colon- # delimited, flat-file db located # at $dbpath # # A sample line of data would # look like this: # # accountname:username:&tc. # #! user/bin/perl -w # # password file location $dbpath = "C:/pw/location.txt"; print "\nPassword Manager v0.3\n\n";
while ($menu !~ /E/i){
print "\nA-Add :: L-List :: S-Search :: E-Exit\n";
$menu = ;
chomp $menu;
if ($menu =~ /A/i){
print "\nAccount Name: ";
my $account = ;
chomp $account;
print "username: ";
my $username = ;
chomp $username;
print "password: ";
my $password = ;
chomp $password;
print "comments: ";
my $comments = ;
chomp $comments;
# Make this into an option to check,
#change the information later
#
#print "\nThis record is being added:\n";
#print "username: $username\n";
#print "password: $password\n";
#print "comments: $comments\n";
#Open output file to append
open (ADDPASS, ">>$dbpath")
|| die "cannot open: $!";
print ADDPASS "$account:$username:";
print ADDPASS "$password:$comments\n";
close (ADDPASS);
print "Record added successfully."
}elsif ($menu =~ /L/i){
open (PASSLIST, "$dbpath");
@list = ;
foreach $line (@list)
{
chomp($line);
print "$line\n";
}
close PASSLIST;
}elsif ($menu =~ /S/i){
print "Account: ";
my $testname = ;
chomp $testname;
print "searching for $testname ...\n";
open (PASSLIST, "$dbpath");
@list = ;
$passflag = 0;
foreach $line (@list){
chomp($line);
@record = split (/:/, $line);
my $accountname = @record[0];
if ($accountname =~ /$testname/i){
$passflag=1;
my $username = @record[1];
my $password = @record[2];
my $comments = @record[3];
if ($comments eq ""){
$comments = "N/A";
}
print "\nFound $accountname\n";
print "\naccount: $accountname\n";
print "username: $username\n";
print "password: $password\n";
print "comments: $comments\n";
}
}
if ($passflag==0) {
print "Record not found.\n";
}
close PASSLIST;
}elsif ($menu =~ /E/i)
{
print "Bye.";
}else
{
print "Unrecognized command";
}
}
print "Bye.";
Comments
That’s fantastic. Congratulations!
I’ve tried keeping track of my passwords in crummy text files, but I never update them and I forget where I put them, so this seems really useful.
I don’t suppose you’re going to code one in Cocoa for us Mac folks… ;)
co-who?
but i do know you can run it on macperl (macperl.com). it’s great! i used to use it on my room-mate’s g3 in dublin.