#!/usr/bin/perl -w use strict; use warnings; use ST2614 1.0; #subroutine guide provides user a simple documentation on how to use the password manager sub guide { my $pwdmgr = shift; print "usage: $pwdmgr L key [site_pattern]\n"; print "-"x5, " takes the encoding key and optional site_pattern to retrieve all saved entries that match.\n If no site_pattern, retrieve all saved entries\n\n"; print "usage: $pwdmgr U key site_name login_id password [URL]\n"; print "-"x5, " Using the encoding key, add new or update existing entry.\n Complete set of entry info required: Site name, login id, password, URL(Optional)\n\n"; print "usage: $pwdmgr D key site_name\n"; print "-"x5, " Takes in encoding key and site_name to delete entry; will only work if encoding key matches and entry found matching with site_name.\n"; exit; } #an if-elsif loop to check which option user has selected if ($ARGV[0] eq "L") { sub listFunct ($;$) { open(FILEHANDLE, "passmgr.dat") or die ("The file cannot be opened!"); my $decode = ST2614::decode(FILEHANDLE, $ARGV[1]); if ( defined $ARGV[2] ) { for $decode (keys =~ m/$ARGV[2]/) { print "$decode: @{ m/$ARGV[2]/ {$decode} }\n"; } } else { for $decode () { print } } } } elsif ($ARGV[0] eq "U") { #declare the individual variables that are to be stored my $sitename = $ARGV[2]; #sitename will be the key in the hash of array my $loginid = $ARGV[3]; my $password = $ARGV[4]; my $url = $ARGV[5]; #declare a hash of array to prepare storage of all variables to be encoded together my HoA {$sitename} = ["$loginid", "$password", "$url"];; open(FILEHANDLE, ">>passmgr.dat") or die("The file cannot be opened!"); my $encode = ST2614::encode(HoA, $ARGV[1]); print FILEHANDLE "$encode"; close FILEHANDLE; print "Data successfully encoded. Please remember your key.\n Your key is $ARGV[1]."; } elsif ($ARGV[0] eq "D") { } else { guide($0); }