>>> generate_key("THE GERMAN ATTACK","SECRET") 'SECRETSECRETSECRE'
(message: str, key: str)
| 12 | # a cyclic manner until it's length isn't |
| 13 | # equal to the length of original text |
| 14 | def generate_key(message: str, key: str) -> str: |
| 15 | """ |
| 16 | >>> generate_key("THE GERMAN ATTACK","SECRET") |
| 17 | 'SECRETSECRETSECRE' |
| 18 | """ |
| 19 | x = len(message) |
| 20 | i = 0 |
| 21 | while True: |
| 22 | if x == i: |
| 23 | i = 0 |
| 24 | if len(key) == len(message): |
| 25 | break |
| 26 | key += key[i] |
| 27 | i += 1 |
| 28 | return key |
| 29 | |
| 30 | |
| 31 | # This function returns the encrypted text |