Mercurial > public > bitcaviar-plus
comparison src/helpers.py @ 0:2327b9eda10f
first commit
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Thu, 14 Oct 2021 21:42:10 +0200 |
parents | |
children | 5b16e6df6a59 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2327b9eda10f |
---|---|
1 def read_bytes(file, number_of_bytes, bytes_order='backward'): | |
2 """ | |
3 Read bytes from buffer | |
4 :param file: <class '_io.BufferedReader'>, required | |
5 :param number_of_bytes: int, required | |
6 :param bytes_order: string, 'backward' or 'forward', required | |
7 :return: string | |
8 """ | |
9 | |
10 # More info about bytes order: https://en.wikipedia.org/wiki/Endianness | |
11 | |
12 b = file.read(number_of_bytes) | |
13 if bytes_order == 'backward': | |
14 b = b[::-1] | |
15 | |
16 b = b.hex().upper() | |
17 | |
18 return b |