В моем коде на Python
Код: Выделить всё
msg = F0C2CA89012A04008C0000000000000000000000
msg_counters = bytes.fromhex(msg)[5:20]
# output: b'*\x04\x00\x8c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
msg_counters_int = int.from_bytes(msg_counters)
# output: 218157641024778742068286256301735936
bin_string = '{:0120b}'.format(msg_counters_int)
print(bin_string)
Код: Выделить всё
001010100000010000000000100011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00101 = 5
01000 = 8
00010 = 2
В моем PHP-коде
Код: Выделить всё
$a = hex2bin("F0C2CA89012A04008C0000000000000000000000");
$b = substr($a, 5, 20);
// output: b"*\x04\x00Œ\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Подробнее здесь: https://stackoverflow.com/questions/788 ... hon-to-php
Мобильная версия