reed%reedloden.com 99ac1271c2 Bug 339471 - [p=reed/LpSolit r=bear]
git-svn-id: svn://10.0.0.236/trunk@217610 18797224-902f-48f8-a5cc-f745e15eee43
2007-01-02 17:38:33 +00:00

27 lines
917 B
Perl
Executable File

#!/usr/bin/perl -wT
if (!defined $ARGV[0]) {
print "Usage: trapdoor PASSWORD\n";
exit 2;
}
# The following code was taking from Bugzilla's bz_crypt() subroutine
# The list of characters that can appear in a salt. Salts and hashes
# are both encoded as a sequence of characters from a set containing
# 64 characters, each one of which represents 6 bits of the salt/hash.
# The encoding is similar to BASE64, the difference being that the
# BASE64 plus sign (+) is replaced with a forward slash (/).
my @saltchars = (0..9, 'A'..'Z', 'a'..'z', '.', '/');
# Generate the salt. We use an 8 character (48 bit) salt for maximum
# security on systems whose crypt uses MD5. Systems with older
# versions of crypt will just use the first two characters of the salt.
my $salt = '';
for ( my $i=0 ; $i < 8 ; ++$i ) {
$salt .= $saltchars[rand(64)];
}
# Crypt the password.
print crypt($ARGV[0], $salt) . "\n";