Data security is of the utmost importance for the modern spy! To keep your logins buttoned up tight, you can build a small, personal password vault and use it to enter up to three passwords for you when connected to a computer at the touch of a capacitive pad on the Gemma M0.

Long, random passwords -- such as [email protected]%2R*qhw8 are great because they're so secure when compared to simple ones such as Pencil or 12345, but can be difficult to remember and to type. Increase your password security by using a long, random string of numbers, letters, and symbols instead of some insecure, easy to remember word. Your Password Vault will remember it for you!

Keep your Gemma M0 Password Vault with you at all times, and then simply plug it into your computer with a USB cable, and touch a capacitive touch pad to auto-type your password, then press Enter on your keyboard.

Code it with CircuitPython 


Follow this guide https://learn.adafruit.com/adafruit-gemma-m0/circuitpython to get started with coding the Gemma M0 in CircuitPython. Install the latest release version of CircuitPython on the board. You may also want to install the Mu editor https://learn.adafruit.com/adafruit-gemma-m0/installing-mu-editor for your coding needs.

Once you can successfully code in Mu and upload to the board, return here.

Here's the code for the Password Vault -- to use it on your Gemma M0 copy it, paste it into Mu, and then save the file as main.py, and then drag it onto the CIRCUITPY drive that shows up when the Gemma M0 is plugged in.

The Gemma M0 can act like a USB HID keyboard, so it’s great for sending key commands. Using the layout.write() command we can have it enter long strings of text, numbers, and punctuation for us!

You'll want to change the three passwords in the code to match your own passwords -- just look for the lines that have the comments # enter your own password here and change the text inside the parenthesis and quotes.

# Gemma M0 Password Vault
# press cap touch pads to enter strong passwords over USB

import time

import board
import touchio
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from digitalio import DigitalInOut, Direction

led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT

touch0 = touchio.TouchIn(board.A0)
touch1 = touchio.TouchIn(board.A1)
touch2 = touchio.TouchIn(board.A2)

# the keyboard object
# sleep for a bit to avoid a race condition on some systems
time.sleep(1)
kbd = Keyboard(usb_hid.devices)
layout = KeyboardLayoutUS(kbd)

while True:
    if touch0.value:
        led.value = True
        print("A0 touched!")
        layout.write("?F3ErPs5.C.m.0.d.S.")  # enter your own password here
        time.sleep(1)

    if touch1.value:
        led.value = True
        print("A1 touched!")
        layout.write("[email protected](WV[vq6N")  # enter your own password here
        time.sleep(1)

    if touch2.value:
        led.value = True
        print("A2 touched!")
        layout.write("[email protected]&")  # enter your own password here
        time.sleep(1)

    time.sleep(0.01)

    print("Waiting for cap touches")
    # turn off the LED
    led.value = False

    time.sleep(0.01)

If you'd like to build a more elaborate version of the Password Vault using a Circuit Playground Express or Circuit Playground Classic, that requires an unlock code to use, check out this guide, the Circuit Playground Password Vault!

This guide was first published on Mar 20, 2018. It was last updated on Mar 20, 2018.

This page (Password Vault) was last updated on Jun 09, 2023.

Text editor powered by tinymce.