Turn the string data, into a list of bits (1, 0)'s
(self, data)
| 414 | self.__create_sub_keys() |
| 415 | |
| 416 | def __String_to_BitList(self, data): |
| 417 | """Turn the string data, into a list of bits (1, 0)'s""" |
| 418 | if _pythonMajorVersion < 3: |
| 419 | # Turn the strings into integers. Python 3 uses a bytes |
| 420 | # class, which already has this behaviour. |
| 421 | data = [ord(c) for c in data] |
| 422 | l = len(data) * 8 |
| 423 | result = [0] * l |
| 424 | pos = 0 |
| 425 | for ch in data: |
| 426 | i = 7 |
| 427 | while i >= 0: |
| 428 | if ch & (1 << i) != 0: |
| 429 | result[pos] = 1 |
| 430 | else: |
| 431 | result[pos] = 0 |
| 432 | pos += 1 |
| 433 | i -= 1 |
| 434 | |
| 435 | return result |
| 436 | |
| 437 | def __BitList_to_String(self, data): |
| 438 | """Turn the list of bits -> data, into a string""" |
no outgoing calls
no test coverage detected