Converts the given string to little-endian in groups of 8 chars. Arguments: string_32 {[string]} -- [32-char string] Raises: ValueError -- [input is not 32 char] Returns: 32-char little-endian string >>> to_little_endian(b'1234567890abcdfghijklmnopqrst
(string_32: bytes)
| 16 | |
| 17 | |
| 18 | def to_little_endian(string_32: bytes) -> bytes: |
| 19 | """ |
| 20 | Converts the given string to little-endian in groups of 8 chars. |
| 21 | |
| 22 | Arguments: |
| 23 | string_32 {[string]} -- [32-char string] |
| 24 | |
| 25 | Raises: |
| 26 | ValueError -- [input is not 32 char] |
| 27 | |
| 28 | Returns: |
| 29 | 32-char little-endian string |
| 30 | >>> to_little_endian(b'1234567890abcdfghijklmnopqrstuvw') |
| 31 | b'pqrstuvwhijklmno90abcdfg12345678' |
| 32 | >>> to_little_endian(b'1234567890') |
| 33 | Traceback (most recent call last): |
| 34 | ... |
| 35 | ValueError: Input must be of length 32 |
| 36 | """ |
| 37 | if len(string_32) != 32: |
| 38 | raise ValueError("Input must be of length 32") |
| 39 | |
| 40 | little_endian = b"" |
| 41 | for i in [3, 2, 1, 0]: |
| 42 | little_endian += string_32[8 * i : 8 * i + 8] |
| 43 | return little_endian |
| 44 | |
| 45 | |
| 46 | def reformat_hex(i: int) -> bytes: |
no outgoing calls
no test coverage detected