Crypt::UnixCrypt_XS(3pm) | User Contributed Perl Documentation | Crypt::UnixCrypt_XS(3pm) |
Crypt::UnixCrypt_XS - perl xs interface for a portable traditional crypt function.
use Crypt::UnixCrypt_XS qw/crypt/; my $hashed = crypt( $password, $salt ); use Crypt::UnixCrypt_XS qw/crypt_rounds fold_password base64_to_block block_to_base64 base64_to_int24 int24_to_base64 base64_to_int12 int12_to_base64/; $block = crypt_rounds( $password, $nrounds, $saltnum, $block ); $password = fold_password( $password ); $block = base64_to_block( $base64 ); $base64 = block_to_base64( $block ); $saltnum = base64_to_int24( $base64 ); $base64 = int24_to_base64( $saltnum ); $saltnum = base64_to_int12( $base64 ); $base64 = int12_to_base64( $saltnum );
This module implements the DES-based Unix crypt function. For those who need to construct non-standard variants of crypt, the various building blocks used in crypt are also supplied separately.
If the salt is an empty string, then the password is ignored and an empty string is returned. The empty salt/hash string is thus used to not require a password.
If the salt string starts with two base 64 digits (from the set [./0-9A-Za-z]), then the password is hashed using the traditional DES-based algorithm. The salt is used to modify the DES algorithm in one of 4096 different ways. The first eight characters of the password are used as a DES key, to encrypt a block of zeroes through 25 iterations of the modified DES. The block output by the final iteration is the hash, and it is returned in base 64 (as eleven digits).
If the salt string starts with an underscore character and then eight base 64 digits then the password is hashed using the extended DES-based algorithm from BSDi. The first four base 64 digits specify how many encryption rounds are to be performed. The next four base 64 digits are used to modify the DES algorithm in one of 16777216 different ways. If the password is longer than eight characters, it is hashed down to eight characters before being used as a key, so all characters of the password are significant.
None by default.
Crypt::UnixCrypt_XS provide a fast portable crypt function. Perl's internal crypt is not present at every system. Perl calls the crypt function of the system's C library. This may lead to trouble if the system's crypt presents different results for the same key and salt, but different processid's. Crypt::UnixCrypt is the cure here, but it is to slow. On my computer Crypt::UnixCrypt_XS is about 800 times faster than Crypt::UnixCrypt.
crypt(3), Crypt::UnixCrypt
Boris Zentner, <bzm@2bz.de>, the original C source code was written by Eric Young, eay@psych.uq.oz.au.
Fixes, Bug Reports, Docs have been generously provided by:
Andrew Main (Zefram) <zefram@fysh.org> Guenter Knauf Thanks!
Copyright (C) 2004, 2005, 2006, 2007 by Boris Zentner
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.
2024-04-01 | perl v5.38.2 |