CasperSecurity

Current Path : /lib/python3/dist-packages/serial/tools/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/serial/tools/__pycache__/hexlify_codec.cpython-310.pyc

o

��^]�	@s�dZddlmZddlZddlZzeWn
eefy!eZYnwdZ	ddd�Z
ddd	�ZGd
d�dej�ZGdd
�d
ej
�Z
Gdd�dej�ZGdd�deej�ZGdd�deej�Zdd�ZdS)aLPython 'hex' Codec - 2-digit hex with spaces content transfer encoding.

Encode and decode may be a bit missleading at first sight...

The textual representation is a hex dump: e.g. "40 41"
The "encoded" data of this is the binary form, e.g. b"@A"

Therefore decoding is binary to text and thus converting binary data to hex dump.

�)�absolute_importN�0123456789ABCDEF�strictcCs t�dd�|��D��t|�fS)�'40 41 42' -> b'@ab'cS�g|]}t|d��qS����int��.0�h�r�</usr/lib/python3/dist-packages/serial/tools/hexlify_codec.py�
<listcomp>(�zhex_encode.<locals>.<listcomp>)�serial�to_bytes�split�len��data�errorsrrr�
hex_encode&s rcCs&td�dd�t�|�D���t|�fS)�b'@ab' -> '40 41 42'�cs��|]
}d�t|��VqdS�z{:02X} N��format�ord�r�brrr�	<genexpr>-��zhex_decode.<locals>.<genexpr>)�unicode�joinr�	iterbytesrrrrr�
hex_decode+s&r(c@s eZdZddd�Zddd�ZdS)�CodecrcCst�dd�|��D��S)rcSrrr	rrrrr3rz Codec.encode.<locals>.<listcomp>)rrr��selfrrrrr�encode1szCodec.encodecC�td�dd�t�|�D���S)rrcsrrrr!rrrr#7r$zCodec.decode.<locals>.<genexpr>�r%r&rr'r*rrr�decode5szCodec.decodeN�r)�__name__�
__module__�__qualname__r,r/rrrrr)0s
r)c@s<eZdZdZddd�Zdd�Zdd�Zd	d
�Zddd
�ZdS)�IncrementalEncoderzIncremental hex encoderrcCs||_d|_dS�Nr)r�state)r+rrrr�__init__=s
zIncrementalEncoder.__init__cCs
d|_dSr5�r6�r+rrr�resetA�
zIncrementalEncoder.resetcCs|jS�Nr8r9rrr�getstateDszIncrementalEncoder.getstatecCs
||_dSr<r8)r+r6rrr�setstateGr;zIncrementalEncoder.setstateFcCs�|j}g}|��D]>}|tvr)t�|�}|r"|�||d@�d}q	d|d>}q	|dkr;|r8|jdkr8td��d}q	|jdkrGtd�|���q	||_t�	|�S)	z�        Incremental encode, keep track of digits and emit a byte when a pair
        of hex digits is found. The space is optional unless the error
        handling is defined to be 'strict'.
        ��r��� rzodd number of hex digitsznon-hex digit found: {!r})
r6�upper�	HEXDIGITS�index�appendr�UnicodeErrorrrr)r+r�finalr6�encoded�c�zrrrr,Js$

�
zIncrementalEncoder.encodeNr0�F)	r1r2r3�__doc__r7r:r=r>r,rrrrr4:s
r4c@seZdZdZddd�ZdS)�IncrementalDecoderzIncremental decoderFcCr-)Nrcsrrrr!rrrr#hr$z,IncrementalDecoder.decode.<locals>.<genexpr>r.)r+rrHrrrr/gszIncrementalDecoder.decodeNrL)r1r2r3rMr/rrrrrNesrNc@�eZdZdZdS)�StreamWriterz-Combination of hexlify codec and StreamWriterN�r1r2r3rMrrrrrPk�rPc@rO)�StreamReaderz-Combination of hexlify codec and StreamReaderNrQrrrrrSorRrSc	Cstjdttttttd�S)zencodings module API�hexlify)�namer,r/�incrementalencoder�incrementaldecoder�streamwriter�streamreader)�codecs�	CodecInforr(r4rNrPrSrrrr�getregentryss�r\r0)rM�
__future__rrZrr%�	NameError�AttributeError�strrDrr(r)r4rNrPrSr\rrrr�<module>s$�


+
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY