当前位置: 首页>>代码示例>>Python>>正文


Python _compat.ZERO_BYTE属性代码示例

本文整理汇总了Python中rsa._compat.ZERO_BYTE属性的典型用法代码示例。如果您正苦于以下问题:Python _compat.ZERO_BYTE属性的具体用法?Python _compat.ZERO_BYTE怎么用?Python _compat.ZERO_BYTE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在rsa._compat的用法示例。


在下文中一共展示了_compat.ZERO_BYTE属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: bytes_leading

# 需要导入模块: from rsa import _compat [as 别名]
# 或者: from rsa._compat import ZERO_BYTE [as 别名]
def bytes_leading(raw_bytes, needle=ZERO_BYTE):
    """
    Finds the number of prefixed byte occurrences in the haystack.

    Useful when you want to deal with padding.

    :param raw_bytes:
        Raw bytes.
    :param needle:
        The byte to count. Default \000.
    :returns:
        The number of leading needle bytes.
    """

    leading = 0
    # Indexing keeps compatibility between Python 2.x and Python 3.x
    _byte = needle[0]
    for x in raw_bytes:
        if x == _byte:
            leading += 1
        else:
            break
    return leading 
开发者ID:Deltares,项目名称:aqua-monitor,代码行数:25,代码来源:transform.py

示例2: bytes_leading

# 需要导入模块: from rsa import _compat [as 别名]
# 或者: from rsa._compat import ZERO_BYTE [as 别名]
def bytes_leading(raw_bytes, needle=ZERO_BYTE):
    '''
    Finds the number of prefixed byte occurrences in the haystack.

    Useful when you want to deal with padding.

    :param raw_bytes:
        Raw bytes.
    :param needle:
        The byte to count. Default \000.
    :returns:
        The number of leading needle bytes.
    '''
    leading = 0
    # Indexing keeps compatibility between Python 2.x and Python 3.x
    _byte = needle[0]
    for x in raw_bytes:
        if x == _byte:
            leading += 1
        else:
            break
    return leading 
开发者ID:deadblue,项目名称:baidupan_shell,代码行数:24,代码来源:transform.py


注:本文中的rsa._compat.ZERO_BYTE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。