#!/usr/bin/perl -w ############################################################################ # Copyright 2000 by AltBlue [IRL: Marius Feraru] # # All rights reserved # # # # Distribute freely, except: # # * don't remove my name from the source or documentation # # (don't take credit for my work) # # * mark your changes # # (don't get me blamed for your possible bugs) # # * don't alter or remove this notice. # # # # No warrantee of any kind, express or implied, is included with this sw. # # Use at your own risk, responsibility for damages (if any) to anyone # # resulting from the use of this software rests entirely with the user. # # # # Send bug reports, bug fixes, enhancements, requests, flames etc., and # # I'll try to keep a version up to date. # # # # I can be reached as follows: # # E-Mail: AltBlue # # Homepage: http://www.deathsdoor.com/altblue # # ICQ: 34435556 # # IRC: N0i-Net (eg: irc.n0i.net) channel: #noi,#linux,#support # ############################################################################ # LAST REVISION: # 2000.07.20 # # TITLE: # DES & MD5 password generator ###### # USAGE: # ./mkpass [] # - if no password supplied, a random password will be picked up. ############################################################################ use strict; use Crypt::PasswdMD5; my $password = defined $ARGV[0] ? $ARGV[0] : random_hash(8,32); print "Password:\t".$password."\nDES:\t\t".crypt($password,random_hash(2,2))."\nMD5:\t\t".unix_md5_crypt($ARGV[0], random_hash())."\n"; exit 0; sub random_hash { my ($ash,$ml) = ('',((defined$_[0]&&$_[0]>0)?$_[0]:4)); my $Ml=(defined$_[1]&&$_[1]>=$ml)?$_[1]:$ml+5; $ash .= ('.','/',0..9,'A'..'Z','a'..'z')[rand 64] foreach(1..($ml+int(rand($Ml-$ml)))); return $ash; }