Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
691 B
4
Indexable
Never
import random


def encrypt(to_encrypt, seed):
    random.seed(seed)
    return [ord(i) + random.randint(1, 1000) % 26 if i != 32 else "" for i in to_encrypt]


def decrypt(to_decrypt, seed):
    random.seed(seed)
    return [i - random.randint(1, 1000) % 26 if i != 32 else "" for i in to_decrypt]


if __name__ == "__main__":
    text = "Ula nie potrafi"
    seed = 0
    print(f"Tekst do szyfrowania: {text}")
    print(f"Ziarno: {seed}\n")

    encrypted = encrypt(text, seed)
    print("Zaszyfrowane:")
    for i in encrypted:
        print(chr(i), end=" ")

    print("\n\nOdszyfrowane:")
    decrypted = decrypt(encrypted, seed)
    for i in decrypted:
        print(chr(i), end=" ")
Leave a Comment