本文整理匯總了Python中cryptography.hazmat.bindings._padding.lib.Cryptography_check_pkcs7_padding方法的典型用法代碼示例。如果您正苦於以下問題:Python lib.Cryptography_check_pkcs7_padding方法的具體用法?Python lib.Cryptography_check_pkcs7_padding怎麽用?Python lib.Cryptography_check_pkcs7_padding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cryptography.hazmat.bindings._padding.lib
的用法示例。
在下文中一共展示了lib.Cryptography_check_pkcs7_padding方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: finalize
# 需要導入模塊: from cryptography.hazmat.bindings._padding import lib [as 別名]
# 或者: from cryptography.hazmat.bindings._padding.lib import Cryptography_check_pkcs7_padding [as 別名]
def finalize(self):
if self._buffer is None:
raise AlreadyFinalized("Context was already finalized.")
if len(self._buffer) != self.block_size // 8:
raise ValueError("Invalid padding bytes.")
valid = lib.Cryptography_check_pkcs7_padding(
self._buffer, self.block_size // 8
)
if not valid:
raise ValueError("Invalid padding bytes.")
pad_size = six.indexbytes(self._buffer, -1)
res = self._buffer[:-pad_size]
self._buffer = None
return res
示例2: finalize
# 需要導入模塊: from cryptography.hazmat.bindings._padding import lib [as 別名]
# 或者: from cryptography.hazmat.bindings._padding.lib import Cryptography_check_pkcs7_padding [as 別名]
def finalize(self):
result = _byte_unpadding_check(
self._buffer, self.block_size,
lib.Cryptography_check_pkcs7_padding)
self._buffer = None
return result