#!/usr/bin/perl # Author: Jason Jorgensen # Description: This little script will generate an OLD_PASSWORD style mysql pass. # If the user does not supply either a plaintext password # one will be generated automatically. # Date: 08/11/2006 # Usage: mysqloldcrypt # Copyright (C) 2001 Jason Jorgensen # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ########################################################################### use String::Random; use Crypt::MySQL qw(password); $rand = new String::Random; print "Usage : mysqloldcrypt \n"; ## Get the password from commandline or generate a random 10 char password if ($ARGV[0]) { $plaintextpassword = $ARGV[0]; print "Supplied Password : $plaintextpassword\n"; } else { $plaintextpassword = $rand->randpattern("ssssssssssssssss"); print "Generated Password : $plaintextpassword\n"; } ## Calculate and display the results $newcryptedpassword = password($plaintextpassword); print "Crypted Password : $newcryptedpassword\n"; exit 0;