File: //proc/722141/root/lib/python3.6/site-packages/yubico/__pycache__/yubico_util.cpython-36.pyc
3
y@�Vz � @ s� d Z dddddgZddlZddlZdd lmZ dd
lmZ ddlmZ dZ d
d� Z
dd� Zdd� Zdd� Z
G dd� d�Zddd�Zdd� Zdd� Zd dd�Zdd� ZdS )!z&
utility functions for Yubico modules
�crc16�validate_crc16�hexdump�
modhex_decode�
hotp_truncate� N� )�__version__)�yubikey_defs)�yubico_exceptioni�� c C s t jdk rt| �S t| �S dS )z#Convert a byte to its integer value� r N)r r )�sys�version_info�ord�int)Zbyte� r �!/usr/lib/python3.6/yubico_util.py�ord_byte s
r c C s t jdk rt| �S t| g�S dS )z1Convert an integer value to a length-1 bytestringr r N)r r )r r
�chr�bytes)Znumberr r r �chr_byte# s
r c C sP d}xF| D ]>}|t |�N }x,td�D ] }|d@ }|dL }|r$|dN }q$W q
W |S )zN
Calculate an ISO13239 CRC checksum of the input buffer (bytestring).
i�� � r i� )r �range)�dataZm_crc�this�_�jr r r r * s
c C s t | �tkS )zs
Validate that the CRC of the contents of buffer is the residual OK value.
The input is a bytestring.
)r �_CRC_OK_RESIDUAL)r r r r r 8 s c @ s0 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
S )�
DumpColorsz> Class holding ANSI colors for colorization of hexdump output c C s dddd�| _ d| _d S )Nz[94mz[92mz[0m)�BLUE�GREEN�RESETT)�colors�enabled)�selfr r r �__init__D s
zDumpColors.__init__c C s | j r|| jkr| j| S dS )ze
Get the ANSI code for 'what'
Returns an empty string if disabled/not found
� )r"