jamroll has asked for the wisdom of the Perl Monks concerning the following question:

i'm using perl's 'crypt' function.

does it have a limit on the size of the string being passed in?

#!/usr/bin/perl # must have's! use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use DBI; use URI::Escape; use lib "/var/www/html/Pm"; my $pw = "Aardvark"; # 8 characters my $salt = "ab"; my $pwCrypted = crypt($pw, $salt); print "content-type: text/plain\n\n"; if (crypt("Aardvarks", $salt) eq $pwCrypted) { print "yup" } else { pr +int "nope"; } exit 1;
the above prints "yup", not "nope" as you might expect....seems crypt does have a limit, although the doc i reference doesn't state the existence of such a limit. is there an equivalent which operates exactly the same?

Replies are listed 'Best First'.
Re: crypt function has string length limit?
by Eily (Monsignor) on Jul 24, 2017 at 15:35 UTC

    The doc actually says:

    Traditionally the result is a string of 13 bytes: two first bytes of the salt, followed by 11 bytes from the set [./0-9A-Za-z], and only the first eight bytes of PLAINTEXT mattered

    Edit: So it depends on the implementation of crypt available on your system, but you can expect bytes after the 8th to be ignored.

Re: crypt function has string length limit?
by Anonymous Monk on Jul 24, 2017 at 15:29 UTC
    With old-school crypt, the maximum password length is 8 characters. None of the documentation seems to mention that explicitly, but it can be inferred from the crypt manpage. I guess that's just one of those things that "everybody knows."
A reply falls below the community's threshold of quality. You may see it by logging in.