crypt.crypt(word, salt=None)
word will usually be a user’s password as typed at a prompt or in a graphical interface. The optional salt is either a string as returned from mksalt()
, one of the crypt.METHOD_*
values (though not all may be available on all platforms), or a full encrypted password including salt, as returned by this function. If salt is not provided, the strongest method will be used (as returned by methods()
.
Checking a password is usually done by passing the plain-text password as word and the full results of a previous crypt()
call, which should be the same as the results of this call.
salt (either a random 2 or 16 character string, possibly prefixed with $digit$
to indicate the method) which will be used to perturb the encryption algorithm. The characters in salt must be in the set [./a-zA-Z0-9]
, with the exception of Modular Crypt Format which prefixes a $digit$
.
Returns the hashed password as a string, which will be composed of characters from the same alphabet as the salt.
Since a few crypt(3) extensions allow different values, with different sizes in the salt, it is recommended to use the full crypted password as salt when checking for a password.
Changed in version 3.3: Accept crypt.METHOD_*
values in addition to strings for salt.
Please login to continue.