A School CryptoParty – A project on eSafety, eSecurity, Cryptography and transitioning from Scratch into Python – Introduction



A School CryptoParty – A project on eSafety, eSecurity, Cryptography and transitioning from Scratch into Python – Introduction

0 0


crypto_edu

A resource on eSafety, eSecurity and Cryptography, assisting students in their transition from Scratch to Python.

On Github MarcScott / crypto_edu

A School CryptoParty

A project on eSafety, eSecurity, Cryptography and transitioning from Scratch into Python

Created by Marc Scott / @coding2learn using reveal.js A School CryptoParty by Marc Scott is licensed under a Creative Commons Attribution 3.0 Unported License.

Objectives

Basic understanding of security - passwords & PIN, access to data etc. Basic understanding of cryptography - ciphers, keys, encrypting and ecrypting Basic understanding of hashing. Basic understanding of Brute Force attacks Understanding of the syntax for Pseudocode to include:
  • I/O (Input and Output), Assigning variables
  • IF/ELSE/ELSEIF
  • FOR loops
  • FUNCTIONS
  • LEN, IF IN
Ability to read through a pseudocode algorithm and predict it's outputs Ability to construct your own pseudocode alogorithms. Understanding of the syntax for Python to include:
  • I/O (Input and Output), Assigning variables
  • if/else/elif
  • for loops
  • functions
  • len,if in
Ability to read through a python algorithm and predict it's outputs Ability to construct a python script from a given pseudocode script.

Contents

Introduction Data and Information

Introduction

Why studying computers is important.

We use computers every day of our lives.

Sometimes we use computers without really knowing they're computers, such as our:

  • Mobile Phones
  • Cars
  • Televisions
  • Supermarket checkouts

It is important that you understand some of the issues and implications of using these computers.

eSaftey, eSecurity and Cryptography

Staying safe and secure while using computers is becoming more and more important.

Governments, Companies and Criminals all want to have as much access to your private information as they can get.

It is important that you learn how to keep yourself safe and secure and that you know some of the theory behind the methods used to protect your information.

Data and Information

What is Data?

Data is little more than a collection of facts and figures.

On it's own data has little meaning or use.

For instance here is some data:

[87,92,78,93,98,85]							
						

What do you think this data means?

Data and Information

Data on it's own is pretty meaningless. It can become information when it is given a context.

For instance;

[87,92,78,93,98,85]							
						

tells us very little on it's own, but if you know that it is the percentage of each Year 9 class in the school, planning on studying Computing at GCSE, now you have some information.

Personal Data

What data is kept on you?

Decide which of the following statements are True and which are False.

My mobile phone company knows where I am whenever my phone is on, within about three miles. My mobile phone company knows who I have called/texted and who has called/texted me. My broadband provider keeps a record of every website I visit. Google keeps a record of eveything I have searched for using their search engine. My email provider scans all the emails I send and receive. Facebook scans every message and post I make and keeps a record of them all. Facebook regularly tracks which websites I visit.

The Answers

They're all True.

  • Whenever we use a connected device such as a mobile phone or computer, our personal data is being collected by various organisations.
  • Most of the time this data collection is harmless and at worse is used to target advertising at us (such as Google scanning our emails).
  • However it is important for you to remember that our computers hold a lot of data about us, that could be used by criminals if they were to gain access to our devices.

Passwords

What is a password?

  • Contrary to their name, passwords do not have to be words.
  • Passwords are combinations of characters commonly found on a keyboard.
  • Passwords are meant to be known by only a single individual.
  • Passwords can be changed by an authenticated user.

Other means of authentication

  • Fingerprints
  • Facial recognition
  • Retinal scanning
  • Voice recognition

The problem with all these forms of authentication, is that the user can't change them. If somebody manages to make copies of your fingerprints, then they could potentially commit identifty fraud, and you are unable to change your own fingerprints.

PIN

Personal Identification Number

PIN in common usage

  • PIN are normally 4 digit numbers.
  • They are still commonly used today in conjunction with Bank cards and mobile phone unlock screens.
  • PIN are probably one of the least secure identification methods available

Writing a program to store a PIN in Python

Asking for and storing a PIN

Our program is going to have to perform a few actions

Ask the user to enter a password. Store that password as a variable.

You probably know how to write this alogrithm already, but before you start we're going to look at some simple pseudocode.

Pseudocode

Pseudocode is a quick and easy way to jot down the the basics of any program you're planning on writing.

Watch the video to see the pseudocode for the first script.

Python

The video below shows how to write the same script in Python

Validating a PIN

Why validate

Computer programs usually ask for validation of PINs and Passwords.

This is to ensure that the user has entered the password or pin correctly

Our next script is going to validate the PIN entry we have just done

Pseudocode

Pseudocode

Python

Using Functions

What are functions?

Functions are named sections of a program or script that perform a specific task.

Functions are useful, as they help to keep our code organised and can be used over and over again in a program.

Pseudocode - getUserPIN()

The first function we're going to create in Pseudocode is one to get the user's PIN

Follow the tutorial below to see how this is accomplished in pseudocode

Python - getUserPIN()

Follow the next tutorial to see how to recreate the function in Python

Calling a function

Once a function is written, it won't run until it has been called.

Watch the tutorial below to learn how to run a function

Functions with Parameters

Functions can have parameters associated with them. Parameters go in the brackets () after a function's name.

Running a function with Arguments.

Things (strings, lists, variables, even other functions) that we pass into functions are called arguments. Watch the video below to see a function being used with Python that has arguments passed into it.

Finishing off the Validate PIN program

Finishing off the Validate PIN program

Watch the video below to see how it can all be tied together to create a complete program. Once you've watched the tutorial, have a go at creating the finished program in Python.

Checking a PIN's length

Inbuilt functions

In most programming languages, there are several functions that are built into the language itself.

One example of an inbuilt function is input() which you have already used.

Another one is len() which checks the length of a string or list.

Using len()

The next tutorial will take you through using len() in your program

checkLength Function in Pseudocode

Let's build a checkLength Function in Pseudocode that we can use in our program.

Adding checkLength to the main program loop

The function you've just created needs calling in the main program loop. Have a go and use the video below if you need to.

Testing the code so far

There's an error in the code. Can you find it?

Run the code and see if you can spot an error - you might have fixed them already though.

Checking a PIN's characters

PIN characters

We want to check that the user is only typing in the numerals 0-9

To do this we're going to need to learn about the in and not in syntax, as well as learning about for loops.

not in

We can check whether a string exists within another string or list of strings using the in syntax. Try typing the following three lines into your interpreter and see what happens.

'b' in 'abc'
'b' in 'def'
'b' not in 'def'

						

more on not in

The following video can show you more

for loops

A for loop will iterate over a range of values, a string or a list.

Try running these lines of code, or skip to the video on the next slide.

for number in range(10):
	print(number)
for letter in 'abcde':
	print(letter)
for item in [1,2,'a','b',3]:
	print(item)						
						

for loops video

Using for and not in to create a function

You might now be able to create a function that checks for acceptable characters.

Using the function in our main loop

We now want to call the function in the main loop. The video below will help if you need it to.

Finishing off the PIN program

Placing the loop in a function

We're going to re-factor out code a little.

This will make it a little more usable.

Extension

Watch the video below for an extension task if you finish early.