summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhpa <hpa>2005-01-24 19:07:55 +0000
committerhpa <hpa>2005-01-24 19:07:55 +0000
commitb05ac381604932345c7ddc61008db021b66749d9 (patch)
tree68fc8265df9a7bedf8363ba5254ee1a492e6f91b
parenta53e2a69acf2074bda1b627baf8a0806152ba5b2 (diff)
downloadsyslinux-b05ac381604932345c7ddc61008db021b66749d9.tar.gz
Allow setting a custom salt
-rwxr-xr-xsha1pass7
1 files changed, 5 insertions, 2 deletions
diff --git a/sha1pass b/sha1pass
index 10ec8b5b..76193f16 100755
--- a/sha1pass
+++ b/sha1pass
@@ -23,7 +23,10 @@ sub random_bytes($) {
return $v;
}
-$salt = MIME::Base64::encode(random_bytes(6), '');
-$pass = Digest::SHA1::sha1_base64($salt, $ARGV[0]);
+
+($pass, $salt) = @ARGV;
+
+$salt = $salt || MIME::Base64::encode(random_bytes(6), '');
+$pass = Digest::SHA1::sha1_base64($salt, $pass);
print '$4$', $salt, '$', $pass, "\$\n";