Is there a way to obscure code using python?

I’m working out a cyber security project in which I’m highlighting to students that starting with anything pre-made, including a chip, ultimately poses security risks and vulnerabilities.

My initial idea is to have them program security devices for a door, using multiple inputs to control a servo. The goal was to provide students with starter code via the publish links, requiring all of them to start with that code. The secret at the end of the project was that I included a “backdoor” via radio signal to open everyone’s doors with one push of a button from my teacher micro:bit.

It seemed promising initially to use the Python editor to write all this code since when I flipped back to the block editor it all only showed as a “python code” gray block. However, after publishing the code and sending it via email to a colleague, all the code shows in that gray block.

Does anyone know how I could further obscure the “backdoor” code, or am I stuck with the code showing up when they open it and I just ask them to not look?

2 Likes

@joelkarl if you open your project in JavaScript, you can add a file to the project using the (+) button on the file explorer underneath the simulator (if you don’t see a file explorer, you might have to make your browser window larger).

Files added this way are not visible/accessible via blocks; they’ll only be able to see them if they switch to javascript and look at the explorer.

3 Likes