diff options
author | hpa <hpa> | 2005-01-21 00:49:46 +0000 |
---|---|---|
committer | hpa <hpa> | 2005-01-21 00:49:46 +0000 |
commit | e8d5cb2b20b82c4e30942834fad8ddb1592bb1db (patch) | |
tree | d968800a7b80406059ba06508b84ed62ddfd89db /sha1pass | |
parent | f7c564216b2d987a1b0b30602fd33536c7f4276e (diff) | |
download | syslinux-e8d5cb2b20b82c4e30942834fad8ddb1592bb1db.tar.gz |
More work on password support for the menu systems. Make the base64
decoder work (necessary to handle encrypted passwords.) Simple
SHA-1 password generator in Perl.
Diffstat (limited to 'sha1pass')
-rwxr-xr-x | sha1pass | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sha1pass b/sha1pass new file mode 100755 index 00000000..10ec8b5b --- /dev/null +++ b/sha1pass @@ -0,0 +1,29 @@ +#!/usr/bin/perl + +use bytes; +use Digest::SHA1; +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; +} + +$salt = MIME::Base64::encode(random_bytes(6), ''); +$pass = Digest::SHA1::sha1_base64($salt, $ARGV[0]); + +print '$4$', $salt, '$', $pass, "\$\n"; |