Skip to main content
100%

Gist 211e4e229b6947bfb6c358c250294083

✓ Published0🌍 Public
Aandyreagan
Last edited Nov 5, 2021
Created on Apr 30, 2021

This example demonstrates a custom encryption and decryption scheme that shuffles a secret string using a permutation key. It shows that the same key can encrypt and restore the original message, while also verifying identity operations, reversal, and manual key swaps. The Python code defines `encrypt` and `decrypt` functions that filter the key to valid indices, then use list comprehensions to reorder characters. It relies on the built-in `random` module with a seeded shuffle to generate test keys, and asserts correctness across multiple scenarios.

AI-generated description

Similar vizzes