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); | |
} |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Perl SHA-512 encrypt function which uses the native libc SHA-512 implementation. Definitely works on Solaris 10 and Linux with glibc > 2.7.