관리-도구
편집 파일: totp.cpython-39.pyc
a f�WcI � @ s� d Z ddlmZmZmZ ddlmZ ddlZddlZddl Z ddl Z e �e�Z ddlZddlZddlZddlZddlZer�ddlmZmZmZmZ n ddlmZmZ ddlmZmZ ddlmZ z.dd lmZ ddlZ ddl!Z dd l"m#Z$ [ W n& e%�y e �&d� d Z$ZY n0 ddl'm(Z( dd l)m*Z*m+Z+m,Z,m-Z- ddl.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 ddl7m8Z8m9Z9m:Z: ddlm;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZD ddlEmFZFmGZG ddlHmIZImJZJmKZK ddlLmMZM g d�ZNejOdk �rddlmPZP dePv�reP�Qd� e �&d� [Pe�Re;d�ejS�ZTg d�ZUdd� ZVd2dd�ZWd d!� ZXeYe$�ZZe�Rd"�Z[G d#d$� d$e\�Z]e�^d%�j_Z`e�^d&�jaZbd'ZcG d(d)� d)e\�ZdG d*d+� d+e4�ZeG d,d-� d-e4�Zfd.e8dd/� fd0d1�ZgdS )3z@passlib.totp -- TOTP / RFC6238 / Google Authenticator utilities.� )�absolute_import�division�print_function)�PY3N)�urlparse� parse_qsl�quote�unquote)r r )r r )�warn)�default_backend)�ciphersz=can't import 'cryptography' package, totp encryption disabled)�exc)� TokenError�MalformedTokenError�InvalidTokenError�UsedTokenError)� to_unicode�to_bytes�consteq�getrandbytes�rng� SequenceMixin� xor_bytes� getrandstr)�BASE64_CHARS� b32encode� b32decode) �u�unicode�native_string_types� bascii_to_str� int_types� num_types�irange�byte_elem_value� UnicodeIO�suppress_cause)� hybrid_method�memoized_property)�lookup_hash�compile_hmac�pbkdf2_hmac)� pbkdf2_sha256)� AppWallet�TOTPr r r r � TotpToken� TotpMatch)� � � )� uses_query�otpauthz4registered 'otpauth' scheme with urlparse.uses_queryz\s|[-=])r3 � � c C sL t D ]}| | s| S qt d }d}t D ]}| | |kr*|}| | }q*|S )zb helper for group_string() -- calculates optimal size of group for given string size. r )�_chunk_sizes)�klen�sizeZbestZrem� r; �0/usr/lib/python3.9/site-packages/passlib/totp.py�_get_group_sizeY s r= �-c s2 t ��}t|�� |�� �fdd�td|� �D ��S )z� reformat string into (roughly) evenly-sized groups, separated by **sep**. useful for making tokens & keys easier to read by humans. c 3 s | ]}�||� � V qd S �Nr; )�.0�o�r: �valuer; r<