Return a Key instance created from bytes_used and chain_size. Creating a new key is easy with this method. Call this class method with the bytes you want the key to recognize along with the size of the chains you want the encryption/decryption processes to use.
(cls, bytes_used, chain_size)
| 48 | |
| 49 | @classmethod |
| 50 | def new(cls, bytes_used, chain_size): |
| 51 | """Return a Key instance created from bytes_used and chain_size. |
| 52 | |
| 53 | Creating a new key is easy with this method. Call this class method |
| 54 | with the bytes you want the key to recognize along with the size of |
| 55 | the chains you want the encryption/decryption processes to use.""" |
| 56 | selection, blocks = list(set(bytes_used)), [] |
| 57 | for _ in range(chain_size): |
| 58 | _CHAOS.shuffle(selection) |
| 59 | blocks.append(bytes(selection)) |
| 60 | return cls(tuple(blocks)) |
| 61 | |
| 62 | def __init__(self, data): |
| 63 | """Initialize the Key instance's variables after testing the data. |
no test coverage detected