summaryrefslogtreecommitdiff
path: root/sha1pass
diff options
context:
space:
mode:
authorhpa <hpa>2005-01-21 00:49:46 +0000
committerhpa <hpa>2005-01-21 00:49:46 +0000
commite8d5cb2b20b82c4e30942834fad8ddb1592bb1db (patch)
treed968800a7b80406059ba06508b84ed62ddfd89db /sha1pass
parentf7c564216b2d987a1b0b30602fd33536c7f4276e (diff)
downloadsyslinux-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-xsha1pass29
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";