diff options
author | Sebastian Schmelzer | 2010-10-25 16:53:54 +0200 |
---|---|---|
committer | Sebastian Schmelzer | 2010-10-25 16:53:54 +0200 |
commit | 3050a9253437f4a4b5ad4bf3b3efdc3c660a5137 (patch) | |
tree | 91ac22153e416aac7ca20916b314b5e2ffa871b1 /contrib/syslinux-4.02/utils/md5pass | |
download | preboot-master.tar.gz preboot-master.tar.xz preboot-master.zip |
Diffstat (limited to 'contrib/syslinux-4.02/utils/md5pass')
-rwxr-xr-x | contrib/syslinux-4.02/utils/md5pass | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/contrib/syslinux-4.02/utils/md5pass b/contrib/syslinux-4.02/utils/md5pass new file mode 100755 index 0000000..3404f1d --- /dev/null +++ b/contrib/syslinux-4.02/utils/md5pass @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +use bytes; +use Crypt::PasswdMD5; +use MIME::Base64; + +sub random_bytes($) { + my($n) = @_; + my($v, $i); + + if ( open(RANDOM, '<', '/dev/random') || + open(RANDOM, '<', '/dev/urandom') ) { + read(RANDOM, $v, $n); + } else { + # No real RNG available... + srand($$ ^ time); + $v = ''; + for ( $i = 0 ; $i < $n ; $i++ ) { + $v .= ord(int(rand() * 256)); + } + } + + return $v; +} + + +($pass, $salt) = @ARGV; + +unless (defined($salt)) { + $salt = MIME::Base64::encode(random_bytes(6), ''); + $salt =~ tr/\+/./; # . not + +} + +print unix_md5_crypt($pass, $salt), "\n"; |