Created
January 5, 2016 12:24
-
-
Save maspalio/1396412fcfc0d9e2f6b0 to your computer and use it in GitHub Desktop.
mkpasswd -m sha-512 $pass $( openssl rand -base64 16 | tr -d '+=' | head -c 16 )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub hashed_password { | |
my ( $pass ) = @_; | |
# mkpasswd -m sha-512 $pass $( openssl rand -base64 16 | tr -d '+=' | head -c 16 ) | |
my $get_salt = sub { | |
my ( $out, $err ); | |
my @command = split ' ', 'openssl rand -base64 16'; | |
run3 \@command, undef, \$out, \$err; | |
chomp $out; | |
$out =~ s/[+=]//g; | |
return substr $out, 0, 16; | |
}; | |
my ( $out, $err ); | |
my @command = split ' ', "mkpasswd -m sha-512 $pass " . $get_salt->(); | |
run3 \@command, undef, \$out, \$err; | |
chomp $out; | |
return $out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment