當前位置: 首頁>>代碼示例>>Python>>正文


Python exceptions.AlreadyFinalized方法代碼示例

本文整理匯總了Python中cryptography.exceptions.AlreadyFinalized方法的典型用法代碼示例。如果您正苦於以下問題:Python exceptions.AlreadyFinalized方法的具體用法?Python exceptions.AlreadyFinalized怎麽用?Python exceptions.AlreadyFinalized使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cryptography.exceptions的用法示例。


在下文中一共展示了exceptions.AlreadyFinalized方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: update

# 需要導入模塊: from cryptography import exceptions [as 別名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 別名]
def update(self, data):
        if self._buffer is None:
            raise AlreadyFinalized("Context was already finalized.")

        if not isinstance(data, bytes):
            raise TypeError("data must be bytes.")

        self._buffer += data

        finished_blocks = max(
            len(self._buffer) // (self.block_size // 8) - 1,
            0
        )

        result = self._buffer[:finished_blocks * (self.block_size // 8)]
        self._buffer = self._buffer[finished_blocks * (self.block_size // 8):]

        return result 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:20,代碼來源:padding.py

示例2: finalize

# 需要導入模塊: from cryptography import exceptions [as 別名]
# 或者: from cryptography.exceptions import AlreadyFinalized [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 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:20,代碼來源:padding.py

示例3: _byte_unpadding_update

# 需要導入模塊: from cryptography import exceptions [as 別名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 別名]
def _byte_unpadding_update(buffer_, data, block_size):
    if buffer_ is None:
        raise AlreadyFinalized("Context was already finalized.")

    if not isinstance(data, bytes):
        raise TypeError("data must be bytes.")

    buffer_ += data

    finished_blocks = max(len(buffer_) // (block_size // 8) - 1, 0)

    result = buffer_[:finished_blocks * (block_size // 8)]
    buffer_ = buffer_[finished_blocks * (block_size // 8):]

    return buffer_, result 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:17,代碼來源:padding.py

示例4: _byte_padding_update

# 需要導入模塊: from cryptography import exceptions [as 別名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 別名]
def _byte_padding_update(buffer_, data, block_size):
    if buffer_ is None:
        raise AlreadyFinalized("Context was already finalized.")

    if not isinstance(data, bytes):
        raise TypeError("data must be bytes.")

    buffer_ += data

    finished_blocks = len(buffer_) // (block_size // 8)

    result = buffer_[:finished_blocks * (block_size // 8)]
    buffer_ = buffer_[finished_blocks * (block_size // 8):]

    return buffer_, result 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:17,代碼來源:padding.py

示例5: _byte_padding_pad

# 需要導入模塊: from cryptography import exceptions [as 別名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 別名]
def _byte_padding_pad(buffer_, block_size, paddingfn):
    if buffer_ is None:
        raise AlreadyFinalized("Context was already finalized.")

    pad_size = block_size // 8 - len(buffer_)
    return buffer_ + paddingfn(pad_size) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:8,代碼來源:padding.py

示例6: _byte_unpadding_check

# 需要導入模塊: from cryptography import exceptions [as 別名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 別名]
def _byte_unpadding_check(buffer_, block_size, checkfn):
    if buffer_ is None:
        raise AlreadyFinalized("Context was already finalized.")

    if len(buffer_) != block_size // 8:
        raise ValueError("Invalid padding bytes.")

    valid = checkfn(buffer_, block_size // 8)

    if not valid:
        raise ValueError("Invalid padding bytes.")

    pad_size = six.indexbytes(buffer_, -1)
    return buffer_[:-pad_size] 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:16,代碼來源:padding.py

示例7: _byte_padding_update

# 需要導入模塊: from cryptography import exceptions [as 別名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 別名]
def _byte_padding_update(buffer_, data, block_size):
    if buffer_ is None:
        raise AlreadyFinalized("Context was already finalized.")

    utils._check_bytes("data", data)

    buffer_ += data

    finished_blocks = len(buffer_) // (block_size // 8)

    result = buffer_[:finished_blocks * (block_size // 8)]
    buffer_ = buffer_[finished_blocks * (block_size // 8):]

    return buffer_, result 
開發者ID:tp4a,項目名稱:teleport,代碼行數:16,代碼來源:padding.py

示例8: _byte_unpadding_update

# 需要導入模塊: from cryptography import exceptions [as 別名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 別名]
def _byte_unpadding_update(buffer_, data, block_size):
    if buffer_ is None:
        raise AlreadyFinalized("Context was already finalized.")

    utils._check_bytes("data", data)

    buffer_ += data

    finished_blocks = max(len(buffer_) // (block_size // 8) - 1, 0)

    result = buffer_[:finished_blocks * (block_size // 8)]
    buffer_ = buffer_[finished_blocks * (block_size // 8):]

    return buffer_, result 
開發者ID:tp4a,項目名稱:teleport,代碼行數:16,代碼來源:padding.py


注:本文中的cryptography.exceptions.AlreadyFinalized方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。