本文整理匯總了Python中hashlib._Hash方法的典型用法代碼示例。如果您正苦於以下問題:Python hashlib._Hash方法的具體用法?Python hashlib._Hash怎麽用?Python hashlib._Hash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hashlib
的用法示例。
在下文中一共展示了hashlib._Hash方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _raise
# 需要導入模塊: import hashlib [as 別名]
# 或者: from hashlib import _Hash [as 別名]
def _raise(self, gots):
# type: (Dict[str, _Hash]) -> NoReturn
raise HashMismatch(self._allowed, gots)
示例2: get_checksum
# 需要導入模塊: import hashlib [as 別名]
# 或者: from hashlib import _Hash [as 別名]
def get_checksum(cls, hash_object=None):
# type: (Optional[hashlib._Hash]) -> hashlib._Hash
"""
Get sha265 checksum of the dockerfile and included files.
Also, include checksums of all required builders.
"""
if hash_object is None:
hash_object = hashlib.sha256()
for builder_cls in cls.REQUIRED_CHECKSUM_IMAGES:
hash_object = builder_cls.get_checksum(hash_object=hash_object)
if cls.IGNORE_CACHING:
return hash_object
dockerfile = cls.get_dockerfile_content()
hash_object.update(dockerfile.encode("utf-8"))
for path in cls.INCLUDE_PATHS:
if path.is_dir():
# TODO implement checksum calculation for directories.
pass
else:
hash_object.update(path.read_bytes())
return hash_object