Python pyasn1.compat.octets.ints2octs() Examples
The following are 30
code examples of pyasn1.compat.octets.ints2octs().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pyasn1.compat.octets
, or try the search function
.
Example #1
Source File: univ.py From xbmc-addons-chinese with GNU General Public License v2.0 | 6 votes |
def fromBinaryString(self, value): bitNo = 8; byte = 0; r = () for v in value: if bitNo: bitNo = bitNo - 1 else: bitNo = 7 r = r + (byte,) byte = 0 if v == '0': v = 0 elif v == '1': v = 1 else: raise error.PyAsn1Error( 'Non-binary OCTET STRING initializer %s' % (v,) ) byte = byte | (v << bitNo) return octets.ints2octs(r + (byte,))
Example #2
Source File: univ.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def fromBinaryString(value): bitNo = 8 byte = 0 r = [] for v in value: if bitNo: bitNo -= 1 else: bitNo = 7 r.append(byte) byte = 0 if v in ('0', '1'): v = int(v) else: raise error.PyAsn1Error( 'Non-binary OCTET STRING initializer %s' % (v,) ) byte |= v << bitNo r.append(byte) return octets.ints2octs(r)
Example #3
Source File: encoder.py From aqua-monitor with GNU Lesser General Public License v3.0 | 6 votes |
def encodeValue(self, encodeFun, value, defMode, maxChunkSize): if value == 0: # shortcut for zero value if self.supportCompactZero: # this seems to be a correct way for encoding zeros return null, 0 else: # this seems to be a widespread way for encoding zeros return ints2octs((0,)), 0 octets = [] value = int(value) # to save on ops on asn1 type while 1: octets.insert(0, value & 0xff) if value == 0 or value == -1: break value = value >> 8 if value == 0 and octets[0] & 0x80: octets.insert(0, 0) while len(octets) > 1 and \ (octets[0] == 0 and octets[1] & 0x80 == 0 or \ octets[0] == 0xff and octets[1] & 0x80 != 0): del octets[0] return ints2octs(octets), 0
Example #4
Source File: encoder.py From baidupan_shell with GNU General Public License v2.0 | 6 votes |
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
Example #5
Source File: univ.py From baidupan_shell with GNU General Public License v2.0 | 6 votes |
def fromBinaryString(self, value): bitNo = 8; byte = 0; r = () for v in value: if bitNo: bitNo = bitNo - 1 else: bitNo = 7 r = r + (byte,) byte = 0 if v == '0': v = 0 elif v == '1': v = 1 else: raise error.PyAsn1Error( 'Non-binary OCTET STRING initializer %s' % (v,) ) byte = byte | (v << bitNo) return octets.ints2octs(r + (byte,))
Example #6
Source File: univ.py From learn_python3_spider with MIT License | 6 votes |
def fromHexString(value): """Create a |ASN.1| object initialized from the hex string. Parameters ---------- value: :class:`str` Text string like 'DEADBEEF' """ r = [] p = [] for v in value: if p: r.append(int(p + v, 16)) p = None else: p = v if p: r.append(int(p + '0', 16)) return octets.ints2octs(r) # Immutable sequence object protocol
Example #7
Source File: univ.py From bash-lambda-layer with MIT License | 6 votes |
def fromHexString(value): """Create a |ASN.1| object initialized from the hex string. Parameters ---------- value: :class:`str` Text string like 'DEADBEEF' """ r = [] p = [] for v in value: if p: r.append(int(p + v, 16)) p = None else: p = v if p: r.append(int(p + '0', 16)) return octets.ints2octs(r) # Immutable sequence object protocol
Example #8
Source File: encoder.py From scalyr-agent-2 with Apache License 2.0 | 6 votes |
def encodeValue(self, encodeFun, value, defMode, maxChunkSize): if value == 0: # shortcut for zero value if self.supportCompactZero: # this seems to be a correct way for encoding zeros return null, 0 else: # this seems to be a widespread way for encoding zeros return ints2octs((0,)), 0 octets = [] value = int(value) # to save on ops on asn1 type while 1: octets.insert(0, value & 0xff) if value == 0 or value == -1: break value = value >> 8 if value == 0 and octets[0] & 0x80: octets.insert(0, 0) while len(octets) > 1 and \ (octets[0] == 0 and octets[1] & 0x80 == 0 or \ octets[0] == 0xff and octets[1] & 0x80 != 0): del octets[0] return ints2octs(octets), 0
Example #9
Source File: encoder.py From scalyr-agent-2 with Apache License 2.0 | 6 votes |
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
Example #10
Source File: univ.py From scalyr-agent-2 with Apache License 2.0 | 6 votes |
def fromBinaryString(self, value): bitNo = 8; byte = 0; r = () for v in value: if bitNo: bitNo = bitNo - 1 else: bitNo = 7 r = r + (byte,) byte = 0 if v == '0': v = 0 elif v == '1': v = 1 else: raise error.PyAsn1Error( 'Non-binary OCTET STRING initializer %s' % (v,) ) byte = byte | (v << bitNo) return octets.ints2octs(r + (byte,))
Example #11
Source File: encoder.py From addon with GNU General Public License v3.0 | 6 votes |
def encodeValue(self, encodeFun, value, defMode, maxChunkSize): if value == 0: # shortcut for zero value if self.supportCompactZero: # this seems to be a correct way for encoding zeros return null, 0 else: # this seems to be a widespread way for encoding zeros return ints2octs((0,)), 0 octets = [] value = int(value) # to save on ops on asn1 type while 1: octets.insert(0, value & 0xff) if value == 0 or value == -1: break value = value >> 8 if value == 0 and octets[0] & 0x80: octets.insert(0, 0) while len(octets) > 1 and \ (octets[0] == 0 and octets[1] & 0x80 == 0 or \ octets[0] == 0xff and octets[1] & 0x80 != 0): del octets[0] return ints2octs(octets), 0
Example #12
Source File: encoder.py From addon with GNU General Public License v3.0 | 6 votes |
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
Example #13
Source File: univ.py From addon with GNU General Public License v3.0 | 6 votes |
def fromBinaryString(self, value): bitNo = 8; byte = 0; r = () for v in value: if bitNo: bitNo = bitNo - 1 else: bitNo = 7 r = r + (byte,) byte = 0 if v == '0': v = 0 elif v == '1': v = 1 else: raise error.PyAsn1Error( 'Non-binary OCTET STRING initializer %s' % (v,) ) byte = byte | (v << bitNo) return octets.ints2octs(r + (byte,))
Example #14
Source File: encoder.py From xbmc-addons-chinese with GNU General Public License v2.0 | 6 votes |
def encodeValue(self, encodeFun, value, defMode, maxChunkSize): if value == 0: # shortcut for zero value if self.supportCompactZero: # this seems to be a correct way for encoding zeros return null, 0 else: # this seems to be a widespread way for encoding zeros return ints2octs((0,)), 0 octets = [] value = int(value) # to save on ops on asn1 type while 1: octets.insert(0, value & 0xff) if value == 0 or value == -1: break value = value >> 8 if value == 0 and octets[0] & 0x80: octets.insert(0, 0) while len(octets) > 1 and \ (octets[0] == 0 and octets[1] & 0x80 == 0 or \ octets[0] == 0xff and octets[1] & 0x80 != 0): del octets[0] return ints2octs(octets), 0
Example #15
Source File: encoder.py From xbmc-addons-chinese with GNU General Public License v2.0 | 6 votes |
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
Example #16
Source File: encoder.py From oss-ftp with MIT License | 6 votes |
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
Example #17
Source File: encoder.py From xbmc-addons-chinese with GNU General Public License v2.0 | 6 votes |
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
Example #18
Source File: univ.py From xbmc-addons-chinese with GNU General Public License v2.0 | 6 votes |
def fromBinaryString(self, value): bitNo = 8; byte = 0; r = () for v in value: if bitNo: bitNo = bitNo - 1 else: bitNo = 7 r = r + (byte,) byte = 0 if v == '0': v = 0 elif v == '1': v = 1 else: raise error.PyAsn1Error( 'Non-binary OCTET STRING initializer %s' % (v,) ) byte = byte | (v << bitNo) return octets.ints2octs(r + (byte,))
Example #19
Source File: univ.py From luci-py with Apache License 2.0 | 6 votes |
def fromHexString(value): """Create a |ASN.1| object initialized from the hex string. Parameters ---------- value: :class:`str` Text string like 'DEADBEEF' """ r = [] p = [] for v in value: if p: r.append(int(p + v, 16)) p = None else: p = v if p: r.append(int(p + '0', 16)) return octets.ints2octs(r) # Immutable sequence object protocol
Example #20
Source File: encoder.py From opsbro with MIT License | 6 votes |
def encodeValue(self, encodeFun, value, defMode, maxChunkSize): if value == 0: # shortcut for zero value if self.supportCompactZero: # this seems to be a correct way for encoding zeros return null, 0 else: # this seems to be a widespread way for encoding zeros return ints2octs((0,)), 0 octets = [] value = int(value) # to save on ops on asn1 type while 1: octets.insert(0, value & 0xff) if value == 0 or value == -1: break value = value >> 8 if value == 0 and octets[0] & 0x80: octets.insert(0, 0) while len(octets) > 1 and \ (octets[0] == 0 and octets[1] & 0x80 == 0 or \ octets[0] == 0xff and octets[1] & 0x80 != 0): del octets[0] return ints2octs(octets), 0
Example #21
Source File: encoder.py From opsbro with MIT License | 6 votes |
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
Example #22
Source File: univ.py From opsbro with MIT License | 6 votes |
def fromBinaryString(self, value): bitNo = 8; byte = 0; r = () for v in value: if bitNo: bitNo = bitNo - 1 else: bitNo = 7 r = r + (byte,) byte = 0 if v == '0': v = 0 elif v == '1': v = 1 else: raise error.PyAsn1Error( 'Non-binary OCTET STRING initializer %s' % (v,) ) byte = byte | (v << bitNo) return octets.ints2octs(r + (byte,))
Example #23
Source File: encoder.py From plugin.video.bdyun with GNU General Public License v3.0 | 6 votes |
def encodeValue(self, encodeFun, value, defMode, maxChunkSize): if value == 0: # shortcut for zero value if self.supportCompactZero: # this seems to be a correct way for encoding zeros return null, 0 else: # this seems to be a widespread way for encoding zeros return ints2octs((0,)), 0 octets = [] value = int(value) # to save on ops on asn1 type while 1: octets.insert(0, value & 0xff) if value == 0 or value == -1: break value = value >> 8 if value == 0 and octets[0] & 0x80: octets.insert(0, 0) while len(octets) > 1 and \ (octets[0] == 0 and octets[1] & 0x80 == 0 or \ octets[0] == 0xff and octets[1] & 0x80 != 0): del octets[0] return ints2octs(octets), 0
Example #24
Source File: encoder.py From plugin.video.bdyun with GNU General Public License v3.0 | 6 votes |
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
Example #25
Source File: univ.py From plugin.video.bdyun with GNU General Public License v3.0 | 6 votes |
def fromBinaryString(self, value): bitNo = 8; byte = 0; r = () for v in value: if bitNo: bitNo = bitNo - 1 else: bitNo = 7 r = r + (byte,) byte = 0 if v == '0': v = 0 elif v == '1': v = 1 else: raise error.PyAsn1Error( 'Non-binary OCTET STRING initializer %s' % (v,) ) byte = byte | (v << bitNo) return octets.ints2octs(r + (byte,))
Example #26
Source File: encoder.py From pelisalacarta-ce with GNU General Public License v3.0 | 6 votes |
def encodeValue(self, encodeFun, value, defMode, maxChunkSize): if value == 0: # shortcut for zero value if self.supportCompactZero: # this seems to be a correct way for encoding zeros return null, 0 else: # this seems to be a widespread way for encoding zeros return ints2octs((0,)), 0 octets = [] value = int(value) # to save on ops on asn1 type while 1: octets.insert(0, value & 0xff) if value == 0 or value == -1: break value = value >> 8 if value == 0 and octets[0] & 0x80: octets.insert(0, 0) while len(octets) > 1 and \ (octets[0] == 0 and octets[1] & 0x80 == 0 or \ octets[0] == 0xff and octets[1] & 0x80 != 0): del octets[0] return ints2octs(octets), 0
Example #27
Source File: encoder.py From pelisalacarta-ce with GNU General Public License v3.0 | 6 votes |
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
Example #28
Source File: univ.py From pelisalacarta-ce with GNU General Public License v3.0 | 6 votes |
def fromBinaryString(self, value): bitNo = 8; byte = 0; r = () for v in value: if bitNo: bitNo = bitNo - 1 else: bitNo = 7 r = r + (byte,) byte = 0 if v == '0': v = 0 elif v == '1': v = 1 else: raise error.PyAsn1Error( 'Non-binary OCTET STRING initializer %s' % (v,) ) byte = byte | (v << bitNo) return octets.ints2octs(r + (byte,))
Example #29
Source File: encoder.py From xunfengES with GNU General Public License v3.0 | 6 votes |
def encodeValue(self, encodeFun, value, defMode, maxChunkSize): if value == 0: # shortcut for zero value if self.supportCompactZero: # this seems to be a correct way for encoding zeros return null, 0 else: # this seems to be a widespread way for encoding zeros return ints2octs((0,)), 0 octets = [] value = int(value) # to save on ops on asn1 type while 1: octets.insert(0, value & 0xff) if value == 0 or value == -1: break value = value >> 8 if value == 0 and octets[0] & 0x80: octets.insert(0, 0) while len(octets) > 1 and \ (octets[0] == 0 and octets[1] & 0x80 == 0 or \ octets[0] == 0xff and octets[1] & 0x80 != 0): del octets[0] return ints2octs(octets), 0
Example #30
Source File: encoder.py From xunfengES with GNU General Public License v3.0 | 6 votes |
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