Skip to content

RiddleScanner

Zach Kysar edited this page May 20, 2016 · 12 revisions

Overview

In this lesson we will be using a barcode scanner to get riddles from QR codes. Then, we will use a substitution cipher to decrypt the text containing the riddles.

Note: You will need to install this android barcode scanner app before starting this project. Most of you should already have it on your phones. (https://play.google.com/store/apps/details?id=com.google.zxing.client.android&hl=en)

New Concepts

Barcode Scanner:

Add these block components to your code to use the phone's barcode scanner. Note that you will need a barcode scanner installed for this to work.

BarcodeScanner

Let's Get Started:

User Interface Designer:

We will need the following components

  • TableLayout(5 columns, 2 rows),
  • 10 TextBox in the TableLayout (width=20% each)
  • 2 Buttons
  • 4 Labels (For Decrypted_Message, and Encrypted_Message: height=20%)
  • BarcodeScanner

DesignerView

Note: TextBoxes BeforeX-AfterX should be arranged like this in the TableLayout

Before1   Before2   Before3   Before4   Before5
After1    After2    After3    After4    After5

Logic :

Variables Setup

  1. Initialize a variable called message to " ".

ScanButton Setup

  1. Call the BarcodeScanner's DoScan

BarcodeScanner Setup

When the BarcodeScanner's AfterScan occurs:

  1. Set the Encrypted_Message to the result of the scan.
  2. Set the variable message to the result of the scan.

TEST

After scanning a qr code, you should see the Encrypted message from the scan appear.

DecryptButton Setup

When you click the DecryptButton:

  1. Set the variable message to the substituted result of the Before and After textboxes, and the message variable.
  2. Do this 5 times, for every pair of the substitution boxes.
  3. Set the Decrypted_Message text to the variable message.

Substituted Result

TEST

Use this key and QR code to test the app.

Test QRCode

====Substitution Cipher Key====
7 = i
4 = o
1 = a
8 = w
3 = m
====Encrypted====
7’3 t1ll 8hen 7’3 y4ung 1nd 7’3 sh4rt 8hen 7’3 4ld. 8h1t 13 7?
====Decrypted====
I’m tall when I’m young and I’m short when I’m old. What am I?

External References:

Stretch Goals

  1. When the barcode scan finishes have the app speak the encrypted riddle to you.
  2. When a decryption of the riddle is complete, have the app speak the decrypted riddle to you.

External References:

  1. Barcode Scanner