Random Useful Scripts
Convert plain text to passwd crypt:
#!/usr/bin/perl
print "Enter the password you would like to use: ";
$pass1 = <STDIN>;
if ($pass1) {
my $salt =
join('', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]);
my $cryptpw = crypt($pass1, $salt);
print "The encrypted password suitable for passwd is $cryptpw\n";
}
Convert base64 encoded to plain text:
#!/usr/bin/perl
use MIME::Base64;
print "Enter the encoded data: ";
$code = <STDIN>;
if ($code) {
my $decrypted = decode_base64($code);
print "The decrypted data is:\n\"$decrypted\"\n";
}
Create 10 random passwords:
#!/usr/bin/perl
sub randomPassword {
my $password;
my $_rand;
my $password_length = $_[0];
if (!$password_length) {
$password_length = 10;
}
my @chars = split(" ",
"a b c d e f g h i j k l m n o
A B C D E F G H I J K L M N O
p q r s t u v w x y z
P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9");
srand;
for (my $i=0; $i <= $password_length ;$i++) {
$_rand = int(rand 62);
$password .= $chars[$_rand];
}
return $password;
}
for ($i=0; $i < 10; $i++){
print randomPassword(8) . "\n";
}
|
|
|
|
|
|
|
|
|
|
|
|