Beispiel #1
0
 def getdata(self):
     """builds an output string of what's currently compressed:
     currently output bit + current tag content"""
     tagstr = _misc.int2lebin(self.__tag, self.__tagsize)
     return _misc.modifystring(self.out, tagstr, self.__tagoffset)
Beispiel #2
0
 def getdata(self):
     """builds an output string of what's currently compressed:
     currently output bit + current tag content"""
     tagstr = _misc.int2lebin(self.__tag, self.__tagsize)
     return _misc.modifystring(self.out, tagstr, self.__tagoffset)
Beispiel #3
0
assert getunkbinstr(2, 1, 8) == "00000001x"
assert getunkbinstr(237, 3, 8) == "011101xxx"

assert gethexstr("\x00") == "00"
assert gethexstr("\x00\x01") == "00 01"
assert gethexstr("abcd") == "61 62 63 64"

assert int2lebin(1, 2) == '\x01\x00'
assert int2lebin(65535, 2) == "\xff\xff"
assert int2lebin(65535, 3) == "\xff\xff\x00"

assert int2bebin(1, 2) == '\x00\x01'

assert md5("") == "d41d8cd98f00b204e9800998ecf8427e"

assert modifystring("abcd", "_", 2) == "ab_d"
assert modifystring("abcde", "=+", 2) == "ab=+e"

assert getlongestcommon("31415926535", "31416")  == 4

assert rol(0x12345678, 8, 32) == 0x34567812
assert rol(0x1234567800, 8, 32) == 0x56780034 # entry value is masked first
assert rol(0x12345678, 8, 64) == 0x1234567800

assert ror(0x12345678, 8, 32) == 0x78123456
assert ror(0x12345678, 8, 64) == 0x7800000000123456

assert byteswap(0x12345678, 4) == 0x78563412
assert byteswap(0x12345678, 2) == 0x7856    #incorrect use but expected result

assert nibbleswap(0x1234, 2) == 0x2143
Beispiel #4
0
assert getunkbinstr(2, 1, 8) == "00000001x"
assert getunkbinstr(237, 3, 8) == "011101xxx"

assert gethexstr("\x00") == "00"
assert gethexstr("\x00\x01") == "00 01"
assert gethexstr("abcd") == "61 62 63 64"

assert int2lebin(1, 2) == '\x01\x00'
assert int2lebin(65535, 2) == "\xff\xff"
assert int2lebin(65535, 3) == "\xff\xff\x00"

assert int2bebin(1, 2) == '\x00\x01'

assert md5("") == "d41d8cd98f00b204e9800998ecf8427e"

assert modifystring("abcd", "_", 2) == "ab_d"
assert modifystring("abcde", "=+", 2) == "ab=+e"

assert getlongestcommon("31415926535", "31416") == 4

assert rol(0x12345678, 8, 32) == 0x34567812
assert rol(0x1234567800, 8, 32) == 0x56780034  # entry value is masked first
assert rol(0x12345678, 8, 64) == 0x1234567800

assert ror(0x12345678, 8, 32) == 0x78123456
assert ror(0x12345678, 8, 64) == 0x7800000000123456

assert byteswap(0x12345678, 4) == 0x78563412
assert byteswap(0x12345678, 2) == 0x7856  #incorrect use but expected result

assert nibbleswap(0x1234, 2) == 0x2143