Projects Personal Contact Rss
 


System Utilities / mkpasswd.pl

Source Text

#!/usr/local/bin/perl
# Small perl program to assist is encrypting passwords
# Paul Gregg <pgregg@pgregg.com>, March 1999.
# http://www.pgregg.com/projects/
if (@ARGV) {
  $pw1 = shift; $seed = shift;
} else {
  system("stty -echo");
  print "Enter a Password: "; $pw1 = <STDIN>;
  print "\nAgain: "; $pw2 = <STDIN>;
  system("stty echo");
  if ($pw1 ne $pw2) { print "Sorry, passwords don't match.\n"; exit; }
  print "\nSeed: "; $seed = substr(<STDIN>,0,2);
}
chomp($seed); chomp($pw1);
if (length($seed) eq 0) {
  srand(time());
  $a = int(rand(25) + 0.5) + (int(rand(1) + 0.5) * 32) + 65;
  $b = int(rand(25) + 0.5) + (int(rand(1) + 0.5) * 32) + 65;
  $seed = sprintf ("%c%c", $a, $b);
}
printf("Encrypted password: %s\n", crypt($pw1, $seed));


  


All content © Paul Gregg, 1994 - 2024
Page last updated: 15 July 2008 23:03:23.
This site https://pgregg.com has been online since 5th October 2000
Previous websites live at various URLs since 1994