dReKurCe has asked for the wisdom of the Perl Monks concerning the following question:
#! /usr/bin/perl our $username; our $name; our $passwd; our $password; our $rot; print ":::this is passwd stickum:::\n"; print "to recover and hide passwords\n"; print "---press any key to begin---\n"; if (<STDIN>){&user}; sub user{ print "Account name:\n"; while (<>){ $username=$_; chomp $username; &query; } sub query{ print "Restore saved?\n"; while (<>){ my $mode=$_; if ($mode=~/yes|y/){ &recordsread; } elsif($mode=~/no|n/){ &recordswrite; } } } sub recordsread{ open(PASSWD, "+</.stickum.txt"); LINE:while (<PASSWD>){ $/="\n"; ($name, $passwrd)=split (/:/); next LINE if($name ne $username); feistal($passwrd); } print "The plaintext is:$rot\n"; close PASSWD; } sub recordswrite{ print "What is the new password?\n"; $passwd=<STDIN>; feistal($password); open (PASSWD "+</.stickum.txt"); EXISITS: while (<PASSWD>){ $\="/n"; $line=$_; next EXISTS unless $line=undef; } print PASSWD "$username:$rot"; close PASSWD; print "Recorded, go ahead and forget\n"; } sub feistal{ $rot=shift@_; $rot=~tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/; return $rot; }
edited: Mon Jun 21 17:58:39 2004 by jeffa - pasted code from user's scratchpad ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Gracefull completion..
by davidj (Priest) on Jun 19, 2004 at 17:16 UTC | |
|
Re: Gracefull completion..
by Roger (Parson) on Jun 19, 2004 at 16:49 UTC |