Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Cybersecurity: Brute Force Attacks & Defenses

Cybersecurity: Brute Force Attacks & Defenses

Decimal Vault PIN

Up to this point, the scripts have used simple PINs with three or four binary digits.  If the scripts instead use decimal digits, the increase in possible combinations improves the security by making it more time consuming to crack the PIN with brute force.

In this activity, you will use scripts that repeat what you’ve done up to now, but with decimal digits in the 0 through 5 range.  Since each digit has six possible values, the number of combinations is:

6 x 6 x 6 = 63 = 216 combinations

 

  • If you are part of a class, and have been assigned a channel, make sure to adjust the script’s channel=7 argument to your assigned channel before you save and flash the scripts.
  • Enter, name, save, and flash the transmitter decimal_pin_pad_transmitter script into the PIN Pad Transmitter micro:bit.
  • Enter, name, save, and flash the decimal_bank_vault_receiver script into the Bank Vault Receiver micro:bit.  Receiver Script (decimal_bank_vault_receiver) is below the Transmitter Script (decimal_pin_pad_transmitter).
  • Before continuing, take a look at the decimal_bank_vault_receiver script’s pin = ’324’ statement.  This is the PIN number you will have to enter into the PIN Pad Transmitter micro:bit’s A/B buttons to gain access.  

Transmitter Script: decimal_pin_pad_transmitter

# decimal_pin_pad_transmitter

from microbit import *
import radio

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

pin = ''
n = 0

while True:

    x = len(pin)
    
    if button_a.was_pressed():
        if n < 5:
            n += 1
            if n is not 0:
                y = n - 1
                display.set_pixel(x, y, 9)
        else:
            for y in range(0, 5):
                display.set_pixel(x, y, 0)
            n = 0
    if button_b.was_pressed():
        pin += str(n)
        n = 0
        if len(pin) == 3:
            radio.send(pin)
            display.scroll(pin)
            pin = ''
            display.clear()

 

Receiver Script: decimal_bank_vault_receiver

# decimal_bank_vault_receiver                 # <- change

from microbit import *
import radio
import random

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

pin = '324'                                   # <- change

while True:

    display.show(Image.SQUARE_SMALL)          # <- change
    
    message = radio.receive()
    
    if message:
        pin_entered = str(message)

        if pin_entered == 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()    

 

Again, let’s check to make sure each micro:bit is running the correct script.  

  • Verify that the decimal PIN Pad Transmitter micro:bit has no lights on.
  • Verify that the decimal Vault Receiver micro:bit shows a square in the center of its display.

Now, as you press and release the A button, LEDs will light from the top downward.  No lights in a column means 0.  One light means 1, and so on, up through five lights for 5.

  • Enter the correct key like this: A A A B A A B A A A A B.
  • Verify that two things happened:
    • The decimal PIN Pad Transmitter micro:bit scrolls 3 2 4 across its display.
    • The decimal Bank Vault Receiver displays a flashing check mark indicating access granted:

 

  • As in the first round, try some other combinations and make sure that they result in the decimal Bank Vault Receiver displaying an X to indicate access denied.

 


Printer-friendly version
Try This: Randomized Vault Key
Prev
How the Decimal Code Works
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress