本文整理汇总了Python中past.builtins.long方法的典型用法代码示例。如果您正苦于以下问题:Python builtins.long方法的具体用法?Python builtins.long怎么用?Python builtins.long使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类past.builtins
的用法示例。
在下文中一共展示了builtins.long方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: format_pgp_key
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def format_pgp_key(key):
"""
Formats PGP key in 16hex digits
:param key:
:return:
"""
if key is None:
return None
if isinstance(key, (int, long)):
return '%016x' % key
elif isinstance(key, list):
return [format_pgp_key(x) for x in key]
else:
key = key.strip()
key = strip_hex_prefix(key)
return format_pgp_key(int(key, 16))
示例2: __init__
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def __init__(self, immediate, size=None):
super(ArmImmediateOperand, self).__init__("")
self._base_hex = True
if type(immediate) == str:
immediate = immediate.replace("#", "")
if '0x' in immediate:
immediate = int(immediate, 16)
else:
immediate = int(immediate)
self._base_hex = False
assert type(immediate) in [int, long], "Invalid immediate value type."
self._immediate = immediate
self._size = size
示例3: __getitem__
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def __getitem__(self, key):
# TODO: Return bytearray or byte instead of str.
if isinstance(key, slice):
chunk = bytearray()
step = 1 if key.step is None else key.step
try:
# Read memory one byte at a time.
for addr in range(key.start, key.stop, step):
chunk.append(self._read_byte(addr))
except IndexError:
logger.warn("Address out of range: {:#x}".format(addr))
raise InvalidAddressError()
return chunk
elif isinstance(key, int) or isinstance(key, long):
return self._read_byte(key)
else:
raise TypeError("Invalid argument type: {}".format(type(key)))
示例4: test_get_value_from_handle_HS_ADMIN
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def test_get_value_from_handle_HS_ADMIN(self):
"""Test retrieving an HS_ADMIN value from a handle record."""
handlerecord = RECORD
handle = handlerecord['handle']
val = self.inst.get_value_from_handle(handle,
'HS_ADMIN',
handlerecord)
self.assertIn('handle', val,
'The HS_ADMIN has no entry "handle".')
self.assertIn('index', val,
'The HS_ADMIN has no entry "index".')
self.assertIn('permissions', val,
'The HS_ADMIN has no entry "permissions".')
syntax_ok = check_handle_syntax(val['handle'])
self.assertTrue(syntax_ok,
'The handle in HS_ADMIN is not well-formatted.')
self.assertIsInstance(val['index'], (int, long),
'The index of the HS_ADMIN is not an integer.')
self.assertEqual(str(val['permissions']).replace('0','').replace('1',''), '',
'The permission value in the HS_ADMIN contains not just 0 and 1.')
示例5: __init__
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def __init__(self, *args, **kwargs):
super(PhaseState, self).__init__(*args, **kwargs)
for m in six.itervalues(self.measurements):
# Using functools.partial to capture the value of the loop variable.
m.set_notification_callback(functools.partial(self._notify, m.name))
self._cached = {
'name': self.name,
'codeinfo': data.convert_to_base_types(self.phase_record.codeinfo),
'descriptor_id': data.convert_to_base_types(
self.phase_record.descriptor_id),
# Options are not set until the phase is finished.
'options': None,
'measurements': {
k: m.as_base_types() for k, m in six.iteritems(self.measurements)},
'attachments': {},
'start_time_millis': long(self.phase_record.record_start_time()),
}
示例6: serialize
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def serialize(v):
if isinstance(v, str):
return v
if isinstance(v, (int, long)):
return zpad(int_to_big_endian(v), 32)
raise NotImplementedError(v)
示例7: hashtopoint
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def hashtopoint(x):
assert isinstance(x, long)
x = x % curve_order
while True:
beta, y = evalcurve(x)
if beta == mulmodp(y, y):
assert isoncurve(x, y)
return FQ(x), FQ(y)
x = addmodn(x, 1)
示例8: getkeys
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def getkeys(self, record):
certtext = self._der2key(record['value'])
if certtext is None:
return
yield Key(record['addr'], record["port"], "ssl", certtext['type'],
int(certtext['len']),
_rsa_construct(long(certtext['exponent']),
long(self.modulus_badchars.sub(
b"", certtext['modulus']
), 16)),
utils.decode_hex(record['infos']['md5']))
示例9: pem2key
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def pem2key(cls, pem):
certtext = cls._pem2key(pem)
return None if certtext is None else _rsa_construct(
long(certtext['exponent']),
long(cls.modulus_badchars.sub(b"", certtext['modulus']), 16),
)
示例10: data2key
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def data2key(data):
data = utils._parse_ssh_key(data)
_, exp, mod = (next(data), # noqa: F841 (_)
long(utils.encode_hex(next(data)), 16),
long(utils.encode_hex(next(data)), 16))
return _rsa_construct(exp, mod)
示例11: process_js_mod
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def process_js_mod(self, data, name, idx, sub_idx):
"""
Processes one moduli from JSON
:param data:
:param name:
:param idx:
:param sub_idx:
:return:
"""
if isinstance(data, (int, long)):
js = collections.OrderedDict()
js['type'] = 'js-mod-num'
js['fname'] = name
js['idx'] = idx
js['sub_idx'] = sub_idx
js['n'] = '0x%x' % data
if self.has_fingerprint(data):
logger.warning('Fingerprint found in json int modulus %s idx %s %s' % (name, idx, sub_idx))
self.mark_and_add_effort(data, js)
if self.do_print:
print(json.dumps(js))
return TestResult(js)
self.process_mod_line(data, name, idx, aux={'stype': 'json', 'sub_idx': sub_idx})
示例12: max_instruction_size
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def max_instruction_size(self):
"""Return the maximum instruction size in bytes.
"""
instruction_size_map = {
ARCH_ARM_MODE_ARM: 4,
# NOTE: THUMB instructions are 2 byte long but THUMBv2
# instruction have both 2 and 4 byte long.
ARCH_ARM_MODE_THUMB: 4,
}
return instruction_size_map[self._arch_mode]
示例13: __init__
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def __init__(self, immediate, size=None):
super(X86ImmediateOperand, self).__init__("")
assert type(immediate) in [int, long], "Invalid immediate value type."
self._immediate = immediate
self._size = size
示例14: _cast_to_bitvec
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def _cast_to_bitvec(value, size):
if type(value) in (int, long):
value = Constant(size, value)
assert type(value) in (Constant, BitVec) and value.size == size
return value
示例15: _can_handle_val
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import long [as 别名]
def _can_handle_val(self, v):
if isinstance(v, (str, unicode)):
return True
elif isinstance(v, bool):
return True
elif isinstance(v, (int, long)):
return True
elif isinstance(v, float):
return True
return False