Target to upload a prerelease
[syslinux.git] / sha1pass
blob26ea76bc63f9574daa0081d1a6df833cd319d9cb
1 #!/usr/bin/perl
3 use bytes;
4 use Digest::SHA1;
5 use MIME::Base64;
7 sub random_bytes($) {
8 my($n) = @_;
9 my($v, $i);
11 if ( open(RANDOM, '<', '/dev/random') ||
12 open(RANDOM, '<', '/dev/urandom') ) {
13 read(RANDOM, $v, $n);
14 } else {
15 # No real RNG available...
16 srand($$ ^ time);
17 $v = '';
18 for ( $i = 0 ; $i < $n ; $i++ ) {
19 $v .= ord(int(rand() * 256));
23 return $v;
27 ($pass, $salt) = @ARGV;
29 $salt = $salt || MIME::Base64::encode(random_bytes(6), '');
30 $pass = Digest::SHA1::sha1_base64($salt, $pass);
32 print '$4$', $salt, '$', $pass, "\$\n";