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


Python octets.int2oct方法代码示例

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


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

示例1: encodeValue

# 需要导入模块: from pyasn1.compat import octets [as 别名]
# 或者: from pyasn1.compat.octets import int2oct [as 别名]
def encodeValue(self, encodeFun, value, defMode, maxChunkSize):
        if not maxChunkSize or len(value) <= maxChunkSize*8:
            out_len = (len(value) + 7) // 8
            out_list = out_len * [0]
            j = 7
            i = -1
            for val in value:
                j += 1
                if j == 8:
                    i += 1
                    j = 0
                out_list[i] = out_list[i] | val << (7-j)
            return int2oct(7-j) + ints2octs(out_list), 0
        else:
            pos = 0; substrate = null
            while 1:
                # count in octets
                v = value.clone(value[pos*8:pos*8+maxChunkSize*8])
                if not v:
                    break
                substrate = substrate + encodeFun(v, defMode, maxChunkSize)
                pos = pos + maxChunkSize
            return substrate, 1 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:25,代码来源:encoder.py

示例2: encodeValue

# 需要导入模块: from pyasn1.compat import octets [as 别名]
# 或者: from pyasn1.compat.octets import int2oct [as 别名]
def encodeValue(self, encodeFun, value, defMode, maxChunkSize):
        if not maxChunkSize or len(value) <= maxChunkSize * 8:
            out_len = (len(value) + 7) // 8
            out_list = out_len * [0]
            j = 7
            i = -1
            for val in value:
                j += 1
                if j == 8:
                    i += 1
                    j = 0
                out_list[i] |= val << (7 - j)
            return int2oct(7 - j) + ints2octs(out_list), 0
        else:
            pos = 0
            substrate = null
            while True:
                # count in octets
                v = value.clone(value[pos * 8:pos * 8 + maxChunkSize * 8])
                if not v:
                    break
                substrate = substrate + encodeFun(v, defMode, maxChunkSize)
                pos += maxChunkSize
            return substrate, 1 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:26,代码来源:encoder.py

示例3: encodeValue

# 需要导入模块: from pyasn1.compat import octets [as 别名]
# 或者: from pyasn1.compat.octets import int2oct [as 别名]
def encodeValue(self, encodeFun, value, defMode, maxChunkSize):
        if not maxChunkSize or len(value) <= maxChunkSize*8:
            r = {}; l = len(value); p = 0; j = 7
            while p < l:
                i, j = divmod(p, 8)
                r[i] = r.get(i,0) | value[p]<<(7-j)
                p = p + 1
            keys = list(r); keys.sort()
            return int2oct(7-j) + ints2octs([r[k] for k in keys]), 0
        else:
            pos = 0; substrate = null
            while 1:
                # count in octets
                v = value.clone(value[pos*8:pos*8+maxChunkSize*8])
                if not v:
                    break
                substrate = substrate + encodeFun(v, defMode, maxChunkSize)
                pos = pos + maxChunkSize
            return substrate, 1 
开发者ID:caronc,项目名称:nzb-subliminal,代码行数:21,代码来源:encoder.py

示例4: encodeValue

# 需要导入模块: from pyasn1.compat import octets [as 别名]
# 或者: from pyasn1.compat.octets import int2oct [as 别名]
def encodeValue(self, value, encodeFun, **options):
        valueLength = len(value)
        if valueLength % 8:
            alignedValue = value << (8 - valueLength % 8)
        else:
            alignedValue = value

        maxChunkSize = options.get('maxChunkSize', 0)
        if not maxChunkSize or len(alignedValue) <= maxChunkSize * 8:
            substrate = alignedValue.asOctets()
            return int2oct(len(substrate) * 8 - valueLength) + substrate, False, True

        # strip off explicit tags
        alignedValue = alignedValue.clone(
            tagSet=tag.TagSet(value.tagSet.baseTag, value.tagSet.baseTag)
        )

        stop = 0
        substrate = null
        while stop < valueLength:
            start = stop
            stop = min(start + maxChunkSize * 8, valueLength)
            substrate += encodeFun(alignedValue[start:stop], **options)

        return substrate, True, True 
开发者ID:aws-samples,项目名称:aws-kube-codesuite,代码行数:27,代码来源:encoder.py

示例5: encodeTag

# 需要导入模块: from pyasn1.compat import octets [as 别名]
# 或者: from pyasn1.compat.octets import int2oct [as 别名]
def encodeTag(self, t, isConstructed):
        tagClass, tagFormat, tagId = t.asTuple()  # this is a hotspot
        v = tagClass | tagFormat
        if isConstructed:
            v = v|tag.tagFormatConstructed
        if tagId < 31:
            return int2oct(v|tagId)
        else:
            s = int2oct(tagId&0x7f)
            tagId = tagId >> 7
            while tagId:
                s = int2oct(0x80|(tagId&0x7f)) + s
                tagId = tagId >> 7
            return int2oct(v|0x1F) + s 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:16,代码来源:encoder.py

示例6: encodeLength

# 需要导入模块: from pyasn1.compat import octets [as 别名]
# 或者: from pyasn1.compat.octets import int2oct [as 别名]
def encodeLength(self, length, defMode):
        if not defMode and self.supportIndefLenMode:
            return int2oct(0x80)
        if length < 0x80:
            return int2oct(length)
        else:
            substrate = null
            while length:
                substrate = int2oct(length&0xff) + substrate
                length = length >> 8
            substrateLen = len(substrate)
            if substrateLen > 126:
                raise Error('Length octets overflow (%d)' % substrateLen)
            return int2oct(0x80 | substrateLen) + substrate 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:16,代码来源:encoder.py

示例7: encodeValue

# 需要导入模块: from pyasn1.compat import octets [as 别名]
# 或者: from pyasn1.compat.octets import int2oct [as 别名]
def encodeValue(self, encodeFun, client, defMode, maxChunkSize):
        if client == 0:
            substrate = int2oct(0)
        else:
            substrate = int2oct(255)
        return substrate, 0 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:8,代码来源:encoder.py

示例8: encodeTag

# 需要导入模块: from pyasn1.compat import octets [as 别名]
# 或者: from pyasn1.compat.octets import int2oct [as 别名]
def encodeTag(self, t, isConstructed):
        tagClass, tagFormat, tagId = t.asTuple()  # this is a hotspot
        v = tagClass | tagFormat
        if isConstructed:
            v = v | tag.tagFormatConstructed
        if tagId < 31:
            return int2oct(v | tagId)
        else:
            s = int2oct(tagId & 0x7f)
            tagId >>= 7
            while tagId:
                s = int2oct(0x80 | (tagId & 0x7f)) + s
                tagId >>= 7
            return int2oct(v | 0x1F) + s 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:16,代码来源:encoder.py

示例9: encodeLength

# 需要导入模块: from pyasn1.compat import octets [as 别名]
# 或者: from pyasn1.compat.octets import int2oct [as 别名]
def encodeLength(self, length, defMode):
        if not defMode and self.supportIndefLenMode:
            return int2oct(0x80)
        if length < 0x80:
            return int2oct(length)
        else:
            substrate = null
            while length:
                substrate = int2oct(length & 0xff) + substrate
                length >>= 8
            substrateLen = len(substrate)
            if substrateLen > 126:
                raise error.PyAsn1Error('Length octets overflow (%d)' % substrateLen)
            return int2oct(0x80 | substrateLen) + substrate 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:16,代码来源:encoder.py


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