本文整理匯總了Python中asn1crypto.core.Integer方法的典型用法代碼示例。如果您正苦於以下問題:Python core.Integer方法的具體用法?Python core.Integer怎麽用?Python core.Integer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類asn1crypto.core
的用法示例。
在下文中一共展示了core.Integer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: compare_primitive_info
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def compare_primitive_info():
return (
(core.ObjectIdentifier('1.2.3'), core.ObjectIdentifier('1.2.3'), True),
(core.Integer(1), Enum(1), False),
(core.Integer(1), core.Integer(1, implicit=5), True),
(core.Integer(1), core.Integer(1, explicit=5), True),
(core.Integer(1), core.Integer(2), False),
(core.OctetString(b''), core.OctetString(b''), True),
(core.OctetString(b''), core.OctetString(b'1'), False),
(core.OctetString(b''), core.OctetBitString(b''), False),
(core.ParsableOctetString(b'12'), core.OctetString(b'12'), True),
(core.ParsableOctetBitString(b'12'), core.OctetBitString(b'12'), True),
(core.UTF8String('12'), core.UTF8String('12'), True),
(core.UTF8String('12'), core.UTF8String('1'), False),
(core.UTF8String('12'), core.IA5String('12'), False),
)
示例2: test_dsa_public_key_unwrap
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_dsa_public_key_unwrap(self):
public = asymmetric.load_public_key(os.path.join(fixtures_dir, 'keys/test-dsa-1024.crt'))
self.assertIsInstance(public.unwrap(), core.Integer)
示例3: test_sequence_spec
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_sequence_spec(self):
seq = Seq()
seq['id'] = '1.2.3'
self.assertEqual(core.Integer, seq.spec('value'))
seq['id'] = '2.3.4'
self.assertEqual(core.OctetString, seq.spec('value'))
示例4: integer
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def integer(self, native, der_bytes):
i = core.Integer(native)
self.assertEqual(der_bytes, i.dump())
self.assertEqual(native, core.Integer.load(der_bytes).native)
示例5: test_load
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_load(self):
i = core.load(b'\x02\x01\x00')
self.assertIsInstance(i, core.Integer)
self.assertEqual(0, i.native)
示例6: test_strict_on_class
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_strict_on_class(self):
with self.assertRaises(ValueError):
core.Integer.load(b'\x02\x01\x00\x00', strict=True)
示例7: test_sequence_any_asn1value
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_sequence_any_asn1value(self):
seq = SequenceAny()
seq.append(core.Integer(5))
self.assertEqual([5], seq.native)
示例8: test_copy
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_copy(self):
a = core.Integer(200)
b = a.copy()
self.assertNotEqual(id(a), id(b))
self.assertEqual(a.contents, b.contents)
self.assertEqual(a.dump(), b.dump())
示例9: test_retag
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_retag(self):
a = core.Integer(200)
b = a.retag('explicit', 0)
self.assertNotEqual(id(a), id(b))
self.assertEqual(a.contents, b.contents)
self.assertNotEqual(a.dump(), b.dump())
示例10: test_untag
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_untag(self):
a = core.Integer(200, explicit=0)
b = a.untag()
self.assertNotEqual(id(a), id(b))
self.assertEqual(a.contents, b.contents)
self.assertNotEqual(a.dump(), b.dump())
示例11: test_fix_tagging_choice
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_fix_tagging_choice(self):
correct = core.Integer(200, explicit=2)
choice = NumChoice(
name='three',
value=core.Integer(200, explicit=1)
)
self.assertEqual(correct.dump(), choice.dump())
self.assertEqual(correct.explicit, choice.chosen.explicit)
choice2 = NumChoiceOldApi(
name='three',
value=core.Integer(200, explicit=1)
)
self.assertEqual(correct.dump(), choice2.dump())
self.assertEqual(correct.explicit, choice2.chosen.explicit)
示例12: test_required_field
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_required_field(self):
with self.assertRaisesRegex(ValueError, '"id" is missing from structure'):
Seq({'value': core.Integer(5)}).dump()
示例13: test_wrong_asn1value
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_wrong_asn1value(self):
with self.assertRaises(TypeError):
Seq({
'id': core.Integer(1),
'value': 1
})
示例14: test_wrong_asn1value2
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_wrong_asn1value2(self):
with self.assertRaises(TypeError):
CopySeq({
'name': core.UTF8String('Test'),
'pair': core.Integer(1)
})
示例15: test_wrong_asn1value3
# 需要導入模塊: from asn1crypto import core [as 別名]
# 或者: from asn1crypto.core import Integer [as 別名]
def test_wrong_asn1value3(self):
with self.assertRaises(TypeError):
NestSeqAny({
'id': '3.4.5',
'value': core.Integer(1)
})