Exemple #1
0
    def test_little_endian_conv(self):
        self.assertEquals(0, util.le2int('\x00'))
        self.assertEquals(1, util.le2int('\x01'))
        self.assertEquals(0xaaff, util.le2int('\xff\xaa'))
        self.assertEquals(0xaabbcc, util.le2int('\xcc\xbb\xaa'))

        self.assertEquals('\x00', util.int2le(0, 1))
        self.assertEquals('\x00\x00', util.int2le(0, 2))
        self.assertEquals('\x01', util.int2le(1, 1))
        self.assertEquals('\x01\x00', util.int2le(1, 2))
        self.assertEquals('\xff\xaa\x00\x00', util.int2le(0xaaff, 4))

        self.assertEquals('\xdd\xcc\xbb\xaa', util.int2le(0xaabbccdd, 4))

        self.assertRaises(ValueError, util.int2le, 0xaabbccdd, 2)
 def canonical_binary_form_public(self, public):
     return util.int2le(public[0], 32)
 def canonical_binary_form_public(self, public):
     return util.int2le(public[0], 32)
 def canonical_binary_form_private(self, private):
     return util.int2le(private, 32)
 def canonical_binary_form_private(self, private):
     return util.int2le(private, 32)