Try This: Randomized Vault Key

If you are doing these activities by yourself, or want to make it to where you won’t have any knowledge of the PIN you are trying to crack, then modify the bank_vault_receiver script to create a random pin.  

Example script: bank_vault_receiver_random_pin

  • Change the bank_vault_receiver project name to bank_vault_receiver_random_pin.
  • Make the changes indicated by the comments below.
  • Save the modified script and flash it into the Bank Vault Receiver micro:bit by clicking Send to micro:bit.
# bank_vault_receiver_random_pin              # <- change

from microbit import *
import radio
import random                                 # <- add                                 

radio.on()
radio.config(channel=7)

sleep(1000)

# pin = '011'                                 # <- comment
pin = ''                                      # <- add
for n in range(3):                            # <- add
    number = str(random.randint(0,1))         # <- add
    pin += number                             # <- add
print("Random pin =", pin)                    # <- add

while True:

    display.set_pixel(2,2,9)
    
    message = radio.receive()
    
    if message:
        if message == pin:
            radio.send("Access granted.")
            for n in range(4):
                display.show(Image.YES)
                sleep(1000)
                display.clear()
                sleep(200)
        else:
            radio.send("Access denied.")
            display.show(Image.NO)
            sleep(3000)

        display.clear()    
  • If the serial monitor is not already open, click Show serial in the micro:bit Python Editor. 
  • Examine the messages from the Bank Vault Receiver micro:bit in the terminal.
  • Try pressing and releasing the reset button a few times (at least 1 second apart). 

Each time you reset the Bank Vault micro:bit, it should display a new random PIN in the terminal.  (Don’t worry if your random sequence is different from what’s shown here.  Yours only has a 1 in 8 chance of matching for any given reset.)

  • Make sure the PIN Pad Transmitter micro:bit is still running bank_vault_crack.
  • Press/release the PIN Pad Transmitter micro:bit’s reset button, then its A button to restart the script and find that randomly determined PIN.

How it Works: vault_receiver_random_pin

In the place of a previously decided PIN, there is now an empty string and a for loop that repeats three times—randomly choosing a 0 or 1- and then appending the pin string with that digit.  

# pin = '011'                                 # <- comment
pin = ''                                      # <- add
for n in range(3):                            # <- add
    number = str(random.randint(0,1))         # <- add
    pin += number                             # <- add
print("Random pin =", pin)                    # <- add