Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import math
- def swap(source: list, index1: int, index2: int):
- source[index1], source[index2] = source[index2], source[index1]
- return source
- def shuffle(source: list, key: any):
- random.seed(key)
- for index1 in range(len(source)):
- index2 = int(math.floor(random.random() * len(source)))
- swap(source, index1, index2)
- return source
- def crossoverCode(source: str, key: any):
- chars = []
- chars.extend(source)
- shuffle(chars, key)
- return ''.join(chars)
- def main():
- print("Введите шифруемое сообщение:")
- source: str = input()
- print("Введите ключ:")
- key: str = input()
- print("Зашифрованное сообщение:", crossoverCode(source, key))
- return True
- main()
Advertisement
Add Comment
Please, Sign In to add comment