HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: //lib/google-cloud-sdk/lib/surface/storage/__pycache__/hash.cpython-312.pyc
�

��&��*�dZddlmZddlmZddlmZddlZddlZddlmZddl	m
Z
ddl	mZdd	l	mZdd
l	m
Z
ddl	mZddl	mZdd
l	mZddlmZddlmZddlmZdZdZdZdZd�Zd�Zd�Zej<Gd�dej>��Z y)zAImplementation of hash command for getting formatted file hashes.�)�absolute_import)�division)�unicode_literalsN)�base)�encryption_util)�errors)�fast_crc32c_util)�flags)�	hash_util)�storage_url)�wildcard_iterator)�resource_reference)�crc32c)�log�
digest_format�crc32c_hash�md5_hash�urlc��|�ytjtj|j	d�jd���j
d�S)z@Converts base64 hash digest to hex-formatted hash digest string.Nz
"'zutf-8)�binascii�hexlify�base64�	b64decode�strip�encode�decode)�
base64_strings �lib/surface/storage/hash.py�_convert_base64_to_hexr*sO�����	�	�	����
�
�
�g�
&�
-�
-�g�
6�8�
9�9?����I�c�V�t|tjtjf�S�N)�
isinstancer�ObjectResource�FileObjectResource)�resources r�_is_object_or_file_resourcer'3s+��	�H�1�@�@�1�D�D�F�
G�Gr c#�PK�d}|D�]}tj|dd��}d}|D]�}t|�r	dx}}|���t|jtj
�s�<|jj
�s�Wtj|jjd�jd��}|D]%}t|tj�s�dx}}|���'��|r��tjdj|����|stjd��y�w)	z8Wildcard matches and recurses into top-level of buckets.FT)�error_on_missing_key�fetch_encrypted_object_hashes�*)r)zNo matches found for {}zNo URLS matched.N)r
�get_wildcard_iteratorr'r#r�CloudUrl�	is_bucket�join�
url_stringrr$r�warning�formatr�InvalidUrlError)�url_strings�any_url_matchedr0�wildcard_expanded_iterator�this_url_matched�wildcard_expanded_resource�bucket_expanded_iterator�bucket_expanded_resources        r�_get_resource_iteratorr;8s$�����/��j�!2�!H�!H��"�&*�",����&@�"�	$�%?�	@�-1�1��*�(�(��1�=�=�"�+�+�
-�&�2�2�<�<�>�#4�#J�#J�&�2�2�7�7��<�G�G�!&�$(� �)A�$�
�0�+�:�:�=�15�5�O�.�*�*�	)A�'A��	�k�k�+�2�2�:�>�?�- �.
�
�
 �
 �!3�
4�4�
�s�A D&�#D&�>AD&�D&�'?D&c�0�eZdZdZddd�Zed��Zd�Zy)�Hashz*Calculates hashes on local or cloud files.ad
      Calculates hashes on local or cloud files that can be used to compare with
      "gcloud storage ls -L" output. If a specific hash option is not provided,
      this command calculates all gcloud storage-supported hashes for the file.

      Note that gcloud storage automatically performs hash validation when
      uploading or downloading files, so this command is only needed if you want
      to write a script that separately checks the hash for some reason.

      If you calculate a CRC32C hash for the file without a precompiled
      google-crc32c installation, hashing will be very slow.
      a

      To get the MD5 and CRC32C hash digest of a cloud object in Base64 format:

        $ {command} gs://bucket/object

      To get just the MD5 hash digest of a local object in hex format:

        $ {command} /dir/object.txt --skip-crc32c --hex
      )�DESCRIPTION�EXAMPLESc� �|jddd��|jddd��|jd	�
�}|jddd��|jd
dd��tj|d	��tj|�y)N�urls�+z'Local or cloud URLs of objects to hash.)�nargs�helpz--hex�
store_truezOOutput hash digests in hex format. By default, digests are displayed in base64.)�actionrDT)�mutexz
--skip-crc32cz@Skip CRC32C hash calculation. Useful if command is running slow.z
--skip-md5z=Skip MD5 hash calculation. Useful if command is running slow.)�command_only_reads_data)�add_argument�	add_groupr
�add_encryption_flags�add_additional_headers_flag)�parser�skip_flags_groups  r�Argsz	Hash.Argsus���
����c� I��K�
����� ��!�
�'�'�d�'�3���!�!���
O�"�Q��!�!���
L�"�N�
���v�t�D�	�%�%�f�-r c#�K�tj|�|jsPtj�rd}nt
jrd}nd}tjdj|��|jrd}t}d�}nd}d�}tj}t|j�D�]�}t |i}t#|t$j&�r�|j(�1|j*�%tj,d	j|���c|j.j0|t2<|js||j(�|t4<|j6s�||j*�|t8<n�|j.j:|t2<|jsO|tj<|j.j:tj>j@��|t4<|j6sO|tj<|j.j:tj>jB��|t8<|�����y�w)
Nzgcloud-crc32c (Go binary)zgoogle-crc32c (Python binary)z(crcmod (slow pure Python implementation)zCRC32C implementation: {}�hexc�"�|j�Sr")�	hexdigest��xs r�<lambda>zHash.Run.<locals>.<lambda>�s
��!�+�+�-r rc��|Sr"�rTs rrVzHash.Run.<locals>.<lambda>�s��ar zNo hashes found for {})"r�initialize_key_store�skip_crc32cr	�should_use_gcloud_crc32cr�IS_FAST_GOOGLE_CRC32C_AVAILABLEr�infor2rQrr�get_base64_hash_digest_stringr;rA�_DIGEST_FORMAT_KEYr#rr$rrr1r�versionless_url_string�_URL_KEY�_CRC32C_HASH_KEY�skip_md5�
_MD5_HASH_KEY�
resource_name�get_hash_from_file�
HashAlgorithm�CRC32C�MD5)�self�args�crc32c_implementation�hash_format�format_cloud_digest�format_file_hash_objectr&�output_dicts        r�RunzHash.Run�s������(�(��.����	�	2�	2�	4� ;���1�1� ?�� J��	�h�h�*�1�1�2G�H�I��x�x��k�2�� 7���k�'�� )� G� G��*�4�9�9�5��
�k��k�
�H�0�?�?�	@����'�H�,=�,=�,E�

�+�+�.�5�5�h�?�
@�
� (� 4� 4� K� K��H�����*=��"�"�+$�+�&�
'��}�}�':�8�;L�;L�'M�+�m�
$� (� 4� 4� B� B��H�����*A��*�*��&�&�4�4��)�)�0�0��+�+�&�
'��}�}�'>��*�*��&�&�4�4��)�)�-�-��(�+�m�
$�
��=6�s�IIN)�__name__�
__module__�__qualname__�__doc__�
detailed_help�staticmethodrOrqrXr rr=r=Vs/��2�
�	
��-�6�.��.�*3r r=)!ru�
__future__rrrrr�googlecloudsdk.callioper�"googlecloudsdk.command_lib.storagerrr	r
rrr
�,googlecloudsdk.command_lib.storage.resourcesr�googlecloudsdk.command_lib.utilr�googlecloudsdk.corerr_rbrdrarr'r;�UniverseCompatible�Commandr=rXr r�<module>r�s���H�&��'�
��(�>�5�?�4�8�:�@�K�2�#�$�� ���
���I�G�
5�<���g�4�<�<�g��gr