Try This: Generate a Random Cryptabet
It takes a while to well and truly shuffle the characters in an alphabet by hand, so why not use a project?
- Enter and flash cryptabet_autogenerate
- Open a terminal and connect it to the micro:bit.
- Wait while it builds the cryptabet with an approach that kind of resembles a brute force attack!
Example project: cryptabet_autogenerate
How It Works
The cryptabet_auto_generator project starts with alpha, which is set to the upper-case alphabet for the sake of example. It repeatedly generates random numbers in the 0…25 range, and then grabs the character at that index from alpha. Then, it checks if that character is already in crypta. If yes, then it discards the character and tries again. If no, then it appends the character to crypta and starts adding the next character.
Pause blocks were added at various points to give the online editor’s terminal enough time to keep up with the stream of text data.
The project uses the length of the alpha string to build the crypta string. So there would be no problem using a custom alphabet, like set alpha to (“vLR{}:,’01234 56789”), for example. That particular alphabet would support dictionaries from the Terminal Control – Go Wireless activity.