[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 #!/usr/bin/perl 2 3 use bytes; 4 use Digest::SHA1; 5 use MIME::Base64; 6 7 sub random_bytes($) { 8 my($n) = @_; 9 my($v, $i); 10 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)); 20 } 21 } 22 23 return $v; 24 } 25 26 27 ($pass, $salt) = @ARGV; 28 29 unless (defined($salt)) { 30 $salt = MIME::Base64::encode(random_bytes(6), ''); 31 } 32 $pass = Digest::SHA1::sha1_base64($salt, $pass); 33 34 print '$4$', $salt, '$', $pass, "\$\n";
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |