%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/hashutil.pyo

�
���^c@@sIdZddlmZmZmZddlZddlZddlZddlZ	ddl
mZddlZ	ddl
Z	ddlZ	ejr�ddlmZeZn"ejr�ddlmZmZndd�Zdd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z dS(u0
A collection of hashing and encoding functions
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tStringIO(tBytesIORumd5cC@sjitdd6tdd6tdd6}|j|�}|dkr`tjjdj|���n||�S(	u%
    Return a checksum digest for a string

    instr
        A string
    checksum : ``md5``
        The hashing algorithm to use to generate checksums. Valid options: md5,
        sha256, sha512.

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.digest 'get salted'
    uhashutil.md5_digestumd5uhashutil.sha256_digestusha256uhashutil.sha512_digestusha512u!Hash func '{0}' is not supported.N(t__salt__tgettNonetsaltt
exceptionstCommandExecutionErrortformat(tinstrtchecksumt
hashing_funcst	hash_func((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pytdigests	cC@sltd|�s.tjjdj|���ntjjj|d�� }td|j�|�}WdQX|S(ui
    Return a checksum digest for a file

    infile
        A file path
    checksum : ``md5``
        The hashing algorithm to use to generate checksums. Wraps the
        :py:func:`hashutil.digest <salt.modules.hashutil.digest>` execution
        function.

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.digest_file /path/to/file
    ufile.file_existsuFile path '{0}' not found.urbuhashutil.digestN(	RR	R
RRtutilstfilestfopentread(tinfileRtft	file_hash((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pytdigest_file8s	cC@stjjj|�S(uO
    Encode a string as base64 using the "modern" Python interface.

    Among other possible differences, the "modern" encoder does not include
    newline ('\n') characters in the encoded output.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.base64_b64encode 'get salted'
    (R	Rt	hashutilstbase64_b64encode(R
((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pyRSscC@stjjj|�S(u�
    Decode a base64-encoded string using the "modern" Python interface

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.base64_b64decode 'Z2V0IHNhbHRlZA=='
    (R	RRtbase64_b64decode(R
((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pyRescC@stjjj|�S(u
    Encode a string as base64 using the "legacy" Python interface.

    Among other possible differences, the "legacy" encoder includes
    a newline ('\n') character after every 76 characters and always
    at the end of the encoded string.

    .. versionadded:: 2014.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.base64_encodestring 'get salted'
    (R	RRtbase64_encodestring(R
((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pyRtscC@s`t�}tjjj|d��}tj||�WdQX|jd�tjjj	|j
��S(u
    Read a file from the file system and return as a base64 encoded string

    .. versionadded:: 2016.3.0

    Pillar example:

    .. code-block:: yaml

        path:
          to:
            data: |
              {{ salt.hashutil.base64_encodefile('/path/to/binary_file') | indent(6) }}

    The :py:func:`file.decode <salt.states.file.decode>` state function can be
    used to decode this data and write it to disk.

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.base64_encodefile /path/to/binary_file
    urbNi(RR	RRRtbase64tencodetseektstringutilstto_strR(tfnamet	encoded_fR((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pytbase64_encodefile�s
	
cC@stjjj|�S(u�
    Decode a base64-encoded string using the "legacy" Python interface

    .. versionadded:: 2014.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.base64_decodestring instr='Z2V0IHNhbHRlZAo='

    (R	RRtbase64_decodestring(R
((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pyR&�s
cC@sAt|�}tjjj|d��}tj||�WdQXtS(u�
    Decode a base64-encoded string and write the result to a file

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.base64_decodefile instr='Z2V0IHNhbHRlZAo=' outfile='/path/to/binary_file'
    uwbN(RR	RRRRtdecodetTrue(R
toutfileR$R((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pytbase64_decodefile�scC@stjjj|�S(u�
    Generate an md5 hash of a given string

    .. versionadded:: 2014.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.md5_digest 'get salted'
    (R	RRt
md5_digest(R
((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pyR+�scC@stjjj|�S(u�
    Generate an sha256 hash of a given string

    .. versionadded:: 2014.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.sha256_digest 'get salted'
    (R	RRt
sha256_digest(R
((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pyR,�scC@stjjj|�S(u�
    Generate an sha512 hash of a given string

    .. versionadded:: 2014.7.0

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.sha512_digest 'get salted'
    (R	RRt
sha512_digest(R
((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pyR-�scC@stjjj|||�S(uP
    Verify a challenging hmac signature against a string / shared-secret

    .. versionadded:: 2014.7.0

    Returns a boolean if the verification succeeded or failed.

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.hmac_signature 'get salted' 'shared secret' 'eBWf9bstXg+NiP5AOwppB5HMvZiYMPzEM9W5YMm/AmQ='
    (R	RRthmac_signature(tstringt
shared_secrettchallenge_hmac((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pyR.�scC@s�|}|}|jd�\}}tjrWtjjj|�}tjjj|�}ntj||t	t
|��}|j�|kS(uo
    Verify a challenging hmac signature against a string / shared-secret for
    github webhooks.

    .. versionadded:: 2017.7.0

    Returns a boolean if the verification succeeded or failed.

    CLI Example:

    .. code-block:: bash

        salt '*' hashutil.github_signature '{"ref":....} ' 'shared secret' 'sha1=bc6550fc290acf5b42283fa8deaf55cea0f8c206'
    u=(tsplitRt	text_typeR	RR!tto_bytesthmactnewtgetattrthashlibt	hexdigest(R/R0R1tmsgtkeythashtypet	challenget	hmac_hash((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pytgithub_signature
s	(!t__doc__t
__future__RRRRR8R5tsalt.exceptionsR	tsalt.extRtsalt.utils.filestsalt.utils.hashutilstsalt.utils.stringutilstPY2RRtPY3tioRRRRRR%R&R*R+R,R-R.R?(((s9/usr/lib/python2.7/site-packages/salt/modules/hashutil.pyt<module>s6							!						

Zerion Mini Shell 1.0