File: //lib64/python3.6/site-packages/zmq/utils/__pycache__/z85.cpython-36.pyc
3
VS�_� � @ sl d Z ddlZddlZejd dkZdZedd� ee�D ��Zdd� e d�D �ddd� Z
d
d� Zdd
� ZdS )z�Python implementation of Z85 85-bit encoding
Z85 encoding is a plaintext encoding for a bytestring interpreted as 32bit integers.
Since the chunks are 32bit, a bytestring must be a multiple of 4 bytes.
See ZMQ RFC 32 for details.
� N� sU 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#c C s g | ]\}}||f�qS � r )�.0�idx�cr r �/usr/lib64/python3.6/z85.py�
<listcomp> s r c C s g | ]}d | �qS )�U r )r �ir r r r s � � c C s� t | �d rtdt | � ��t | �d }tjd| | �}g }x0|D ](}x"tD ]}|jt|| d � qLW qBW trzt|�S dj |�S dS )zencode raw bytes into Z85� z$length must be multiple of 4, not %iz>%dIr � N)
�len�
ValueError�struct�unpack�_85s�append�Z85CHARS�PY3�bytes�join)Zrawbytes�nvalues�valuesZencoded�v�offsetr r r �encode s
r c C s� t r:t| t�r:y| jd�} W n tk
r8 td��Y nX t| �d rVtdt| � ��t| �d }g }xTtdt| �d�D ]@}d}x,tt �D ] \}}|t
| || | 7 }q�W |j|� qxW tj
d| f|�� S )z3decode Z85 bytes to raw bytes, accepts ASCII string�asciiz4string argument should contain only ASCII charactersr z(Z85 length must be multiple of 5, not %ir z>%dI)r �
isinstance�strr �UnicodeEncodeErrorr r �range� enumerater �Z85MAPr r �pack)Zz85bytesr r r
�value�jr r r r �decode, s r( ���)
�__doc__�sysr �version_infor r �dictr# r$ r"