當前位置: 首頁>>代碼示例>>Python>>正文


Python core.Integer方法代碼示例

本文整理匯總了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),
        ) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:18,代碼來源:test_core.py

示例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) 
開發者ID:wbond,項目名稱:oscrypto,代碼行數:5,代碼來源:test_asymmetric.py

示例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')) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:8,代碼來源:test_core.py

示例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) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:6,代碼來源:test_core.py

示例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) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:6,代碼來源:test_core.py

示例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) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:5,代碼來源:test_core.py

示例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) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:6,代碼來源:test_core.py

示例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()) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:8,代碼來源:test_core.py

示例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()) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:8,代碼來源:test_core.py

示例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()) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:8,代碼來源:test_core.py

示例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) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:16,代碼來源:test_core.py

示例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() 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:5,代碼來源:test_core.py

示例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
            }) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:8,代碼來源:test_core.py

示例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)
            }) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:8,代碼來源:test_core.py

示例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)
            }) 
開發者ID:wbond,項目名稱:asn1crypto,代碼行數:8,代碼來源:test_core.py


注:本文中的asn1crypto.core.Integer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。