%PDF- %PDF-
| Direktori : /lib/python3.9/site-packages/passlib/handlers/__pycache__/ |
| Current File : //lib/python3.9/site-packages/passlib/handlers/__pycache__/windows.cpython-39.pyc |
a
f�Wc`0 � @ s� d Z ddlmZ ddlZe�e�ZddlmZ ddl m
Z
mZ ddlm
Z
ddlmZ ed�jZddlm mZ g d �ZG d
d� dejejej�ZG dd
� d
ej�Zejdedddd�ZG dd� dejej�ZG dd� dejej�Z dS )z;passlib.handlers.nthash - Microsoft Windows -related hashes� )�hexlifyN)�warn)�
to_unicode�right_pad_string)�unicode)�lookup_hash�md4)�lmhash�nthash�
bsd_nthash�msdcc�msdcc2c @ sP e Zd ZdZd ZdZejZdZ dZ
dZedd� �Z
dd � Zd
Zeddd
��ZdS )r a� This class implements the Lan Manager Password hash, and follows the :ref:`password-hash-api`.
It has no salt and a single fixed round.
The :meth:`~passlib.ifc.PasswordHash.using` method accepts a single
optional keyword:
:param bool truncate_error:
By default, this will silently truncate passwords larger than 14 bytes.
Setting ``truncate_error=True`` will cause :meth:`~passlib.ifc.PasswordHash.hash`
to raise a :exc:`~passlib.exc.PasswordTruncateError` instead.
.. versionadded:: 1.7
The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.verify` methods accept a single
optional keyword:
:type encoding: str
:param encoding:
This specifies what character encoding LMHASH should use when
calculating digest. It defaults to ``cp437``, the most
common encoding encountered.
Note that while this class outputs digests in lower-case hexadecimal,
it will accept upper-case as well.
)Ztruncate_error� � �cp437c C s |� � S �N��lower��cls�hash� r �</usr/lib/python3.9/site-packages/passlib/handlers/windows.py�
_norm_hashU s zlmhash._norm_hashc C s( | j r| �|� t| �|| j���d�S �N�ascii)Zuse_defaultsZ_check_truncate_policyr �raw�encoding�decode��self�secretr r r �_calc_checksumY s
zlmhash._calc_checksums KGS!@#$%Nc C s� |s
| j }ddlm} | j}t|t�r6|�� �|�}nt|t�rJ|�� }nt d��t
|d�}||dd� |�||dd� |� S )a� encode password using LANMAN hash algorithm.
:type secret: unicode or utf-8 encoded bytes
:arg secret: secret to hash
:type encoding: str
:arg encoding:
optional encoding to use for unicode inputs.
this defaults to ``cp437``, which is the
common case for most situations.
:returns: returns string of raw bytes
r )�des_encrypt_blockzsecret must be unicode or bytesr � )�default_encodingZpasslib.crypto.desr# �_magic�
isinstancer �upper�encode�bytes� TypeErrorr )r r! r r# �MAGICr r r r c s
�z
lmhash.raw)N)�__name__�
__module__�__qualname__�__doc__�nameZsetting_kwds�uh� HEX_CHARS�checksum_chars�
checksum_sizeZ
truncate_sizer% �classmethodr r"