Created
July 16, 2012 09:28
-
-
Save beezly/3121789 to your computer and use it in GitHub Desktop.
SHA512 crypt function
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
use String::Random qw(random_regex); | |
sub encrypt { | |
my $password = shift; | |
my $salt = random_regex('[0-9A-Za-z./]{16}'); | |
return crypt($password,'$6$'.$salt); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want a cross platform implementation that doesn't depend on the libc crypt, it's probably worth looking at this: http://stackoverflow.com/questions/11017330/creating-glibc-2-7-style-sha-512-crypt-hashes-in-perl