o nnh @sddlmZddlZddlmZzddlmZWn ey#dZYnwddlm Z ddl m Z efddZ efd d Z e Ze Zd d Zd dZdS)) annotationsN)sha1)md5) AnsibleError)to_bytescCs$|}t|dd}|||S)z* Return a secure hash hex digest of data. surrogate_or_stricterrors)rupdate hexdigest)data hash_funcdigestr@/usr/local/lib/python3.10/dist-packages/ansible/utils/hashing.py secure_hash_s"s  rc Cstjt|ddrtjt|ddrdS|}d}z%tt|ddd}||}|r8||||}|s,|W| St yT}zt d||fd}~ww)z\ Return a secure hash hex digest of local file, None if file is not present or a directory. rrstrictNirbz0error while accessing the file %s, error was: %s) ospathexistsrisdiropenreadr closeIOErrorrr )filenamer r blocksizeinfileblockerrr secure_hash+s"(    r!cCtstdt|tSNz1MD5 not available. Possibly running in FIPS mode)_md5 ValueErrorr)r rrrmd5sN r&cCr"r#)r$r%r!)rrrrrTr'r) __future__rrhashlibrrr$ ImportErroransible.errorsr+ansible.module_utils.common.text.convertersrrr!checksum checksum_sr&rrrrs