krl gl drlrpcj cpr ougei tm arjgrvr tfct wfgef tfry wgqf tm ar tpur.

Similar documents
PROJECT 2: Encoding Assistants CSE100/INFO100 Fluency with Information Technology Spring 2002

EECS2031 Winter Software Tools. Assignment 2 (15%): C Programming

Python allows variables to hold string values, just like any other type (Boolean, int, float). So, the following assignment statements are valid:

BEGINNER PHP Table of Contents

The Caesar Cipher Informatics 1 Functional Programming: Tutorial 3

Worksheet - Reading Guide for Keys and Passwords

Lab 4: Strings/Loops Due Apr 22 at midnight

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object

CS 105: Introduction to Computer Programming (using JavaScript) Quiz: Khan Academy: Intro to While Loop

A cipher is a type of secret code, where you swap the letters around so that noone can read your message.

CS 105 Introduction to Computer Programming in JavaScript Midterm Exam Review

CS 135: Fall Project 2 Simple Cryptography

CMPSCI 187 / Spring 2015 Hangman

Due: March 8, 11:59pm. Project 1

The little book of programming challenges

Problem A A New Alphabet

General Certificate of Secondary Education For submission in 2016

Modern Cryptography Activity 1: Caesar Ciphers

CS 351: Design of Large Programs.

Accessing your online class

Due Date: Two Program Demonstrations (Testing and Debugging): End of Lab

ENGR/CS 101 CS Session Lecture 5

CS 2316 Pair 1: Homework 3 Enigma Fun Due: Wednesday, February 1st, before 11:55 PM Out of 100 points

CSE 154, Autumn 2012 Final Exam, Thursday, December 13, 2012

COL100 Lab 9. I semester Week 9, To be able to write C programs involving functions and recursion.

CSC 580 Cryptography and Computer Security

The goal of this project is to design an FPGA-based cipher unit for the Xilinx Spartan II XC2S100 FPGA running on the XESS board.

CS 556 Spring 2017 Project 3 Study of Cryptographic Techniques

2

CSCI 1301: Introduction to Computing and Programming Spring 2018 Project 3: Hangman 2.0 (A Word Guessing Game)

Polyalphabetic cyphers

Alfresco Voice Writing for the user interface

ECE 206, Fall 2001: Lab 3

Office Wo Office W r o d r 2007 Revi i ng and R d Refifini ng a D Document

Today s topics. Announcements/Reminders: Characters and strings Review of topics for Test 1

Welcome to Book Display Widgets

Paper Proof Manual. As a Student... Paper Proof Manual

Information Systems Security

Programming Lab 1 (JS Hwk 3) Due Thursday, April 28

LAB: Public-Key Encryption

To practice overall problem-solving skills, as well as general design of a program

CSC105, Introduction to Computer Science I. Introduction. Perl Directions NOTE : It is also a good idea to

Semester 2, 2018: Lab 5

CS3 Midterm 1 Fall 2007 Standards and solutions

Introduction to Cryptography CS 136 Computer Security Peter Reiher October 9, 2014

P2_L6 Symmetric Encryption Page 1

NUMB3RS Activity: Creating Codes. Episode: Backscatter

DEPARTMENT OF MATHS, MJ COLLEGE

ISA 562: Information Security, Theory and Practice. Lecture 1

Computers and Security

Problem Description Earned Max 1 HTML / CSS Tracing 20 2 CSS 20 3 PHP 20 4 JS / Ajax / JSON 20 5 SQL 20 X Extra Credit 1 TOTAL Total Points 100

Wix Website. Project overview. Step 1: Log onto a web browser and go to Step 2: Click Start Now. Step 3: Click Sign up

p1: Fortune 1. Overview 2. Learning Goals 3. Logistics 4. Linux commands

Substitution Ciphers, continued. 3. Polyalphabetic: Use multiple maps from the plaintext alphabet to the ciphertext alphabet.

Encryption Using Timing Clock YAHYA LAYTH KHALEEL, MUSTAFA ABDULFATTAH HABEEB, RAGHAD ABDULRAHMAN SHABAN

Sankalchand Patel College of Engineering, Visnagar B.E. Semester V (CE/IT) INFORMATION SECURITY Practical List

Faculty Training. Blackboard I Workshop Bobbi Dubins

Welcome to Book Display Widgets

CSEC 507: APPLIED CRYPTOLOGY Historical Introduction to Cryptology

FAU. How do I. Post course content? Folders

ECE2049: Homework 1. Due: Thursday, 25 May 2017 by 7pm

Introduction to Cryptology. Lecture 2

Introduction to Cryptology ENEE 459E/CMSC 498R. Lecture 1 1/26/2017

Student, Perfect Final Exam May 25, 2006 ID: Exam No CS-081/Vickery Page 1 of 6

Cryptographic Techniques. Information Technologies for IPR Protections 2003/11/12 R107, CSIE Building

Honors Computer Science Python Mr. Clausen Programs 4A, 4B, 4C, 4D, 4E, 4F

Cryptography Lesson Plan

CSCE 813 Internet Security Symmetric Cryptography

Problem Description Earned Max 1 HTML / CSS Tracing 20 2 CSS 20 3 PHP 20 4 JS / Ajax / JSON 20 5 SQL 20 X Extra Credit 1 TOTAL Total Points 100

Module 1: Classical Symmetric Ciphers

Cryptography Worksheet

JavaScript Basics. The Big Picture

Stratford School Academy Schemes of Work

Getting Started in Your Blackboard 5 Course

2/7/2013. CS 472 Network and System Security. Mohammad Almalag Lecture 2 January 22, Introduction To Cryptography

OVE EDFORS ELECTRICAL AND INFORMATION TECHNOLOGY

CSCE 715: Network Systems Security

1 Brief Overview Of the talk

LoiLoNote School User Registration Manual

Figure 1 Forms category in the Insert panel. You set up a form by inserting it and configuring options through the Properties panel.

Math236 Discrete Maths with Applications

Strings, Lists, and Sequences

ENGR/CS 101 CS Session Lecture 9

Appendix C. Numeric and Character Entity Reference

Open GL Framework For A Computer Graphics Course

Problem Set 2 Out of 45 points Due Thursday, September 27, 2012 at 8pm

Strings in Python: Cipher Applications CS 8: Introduction to Computer Science Lecture #7

Hotmail Documentation Style Guide

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

UNIVERSITY OF TECHNOLOGY SYDNEY FACULTY OF ENGINEERING AND IT. Let's code with! DOCUMENTATION, MATERIAL, RESOURCES. (version 2)

CS150 Assignment 7 Cryptography

Chapter 2: Working with the Windows 7 Desktop

Unit E Step-by-Step: Programming with Python

Traditional Symmetric-Key Ciphers. A Biswas, IT, BESU Shibpur

Algebraic Solutions of Caesar and Multiplicative Ciphers

Information Security

Let s make a web game! credit: Photon Storm

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.

The second statement selects character number 1 from and assigns it to.

Cryptography I ALFE APRTGHAL KAP BQQQ ADCQTPEMY KSANG A KGA-ETAM MFLK FQRUQY

Transcription:

CS-105 Cryptogram Game Instructor: Joel Castellanos e-mail: joel@unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center (FEC) room 319 krl gl drlrpcj cpr ougei tm arjgrvr tfct wfgef tfry wgqf tm ar tpur. 3/30/2017 Quiz: Which Image is Drawn? //Assume the canvas is 200x200 pixels var i = 0; while (i<=200) { line(0, 0, 200, i); //x 1,y 1,x 2,y 2 i += 10; } 2 a) b) c) d) 1

Cryptogram Game 3 Code Cracker is a one player game. The computer chooses a plain text sentence from a database. The computer then generates a random mapping of plain text letters to cypher letters. The computer then displays the encrypted sentence by replacing each plain text letter with an encrypted letter. Spaces and punctuation marks are left unencrypted. The player makes a guess in the form of z = e. If the guess is correct, the computer replaces each instance of the encrypted letter with each instance of the unencrypted letter. Caesar Cipher A B C D E F G... X Y Z A B C D E F G H I J... The Caesar Cipher is named after Julius Caesar, who used it with a wrap around shift of 3, to protect messages of military significance. If he had anything confidential to say, he wrote it in cipher, that is, by so changing the order of the letters of the alphabet, that not a word could be made out. If anyone wishes to decipher these, and get at their meaning, he must substitute the fourth letter of the alphabet, namely D, for A, and so with the others. Suetonius, Life of Julius Caesar 56 4 2

Substitution Cipher A substitution cipher is a method of encryption by which units of plaintext are replaced with ciphertext according to fixed, bijection. The bijection (one-to-one onto map) is created as a random mapping.. Example: Clear Text: HELLO WORLD! Encrypted Text: zquuw swxuj! ABCDEFGHIJKLMNOPQRSTUVWXYZ nfdjqyazkpcutgwmbxhovisrle 5 Guessing Process ABCDEFGHIJKLMNOPQRSTUVWXYZ nfdjqyazkpcutgwmbxhovisrle Given a random map and the encrypted text: zquuw swxuj! The player guesses: u = L. Then the game displays: zqllw swxlj! Next the player guesses: z = H. Then the game displays: etc. HqLLw swxlj! 6 3

Lab Requirements: Clear Text Start with the provided CryptogramGame.html. This program has an input field for the text to be encrypted. Your program must NOT take user input for the clear text. Your program must include at least 20 messages in an array of strings. When your page loads, your program must randomly choose one of the messages. Your 20+ messages must have a unifying theme: Quotes from a book or film series, quotes from famous soccer players or politicians or jokes,... Each message must be at least one complete sentence and must be twelve to thirty words long. 7 Use only lower-case (no capitals) in your clear text. Lab Requirements: Cypher Text (1 of 2) The given program builds an alphabet array. Then copies that array, then builds a map by randomly shuffling the letters in the map array. That code may used unchanged. The given program uses the canvas to display each letter of the clear text, each step in encrypting each letter and the final encrypted letter. 8 Your program must NOT display the clear text nor the steps of encryption. Your program must write only the encrypted message to an HTML label with word-wrap enabled. Note: the example program has two word-wrap labels: one used for the map and one for the alphabet. Since your program will display neither the map nor the alphabet, use one of these labels for the encrypted message and delete the other. 4

Lab Requirements: Cypher Text (2 of 2) The given program encrypts each letter of the message, but just displays it in square brackets. Your program needs to build a new totally encrypted message. One way to do this is to create a new variable equal to an empty string: var cypher = ""; Then in a loop, like the given loop that prints each encrypted letter, append each encrypted letter to cypher. As the player makes correct guesses, replace the lowercase encrypted letters in cypher with upper-case clear-text letters. 9 Lab Requirements: Punctuation The given program copies spaces and exclamation points as clear text into the encrypted message. Your program must do the same and additionally leave commas, periods, question marks, colons, semicolons, apostrophe and hyphens unencrypted. 10 5

Lab Requirements: Player Guesses The given program has an HTML text input field into which the user can type a clear text word. The JavaScript code reads the input field and encrypts each letter. Your program does not take user input for the clear text message, but does need to have two text input field in order to get the player's guess. 11 To make a guess, the player: 1) Enters a single encrypted letter in one input field. 2) Enters a single letter in the second input field that the player is guessing the entered encrypted letter represents. 3) Clicks a "Make Guess" button. Lab Requirements: Guess Results When the player guesses correctly, your program must 1) Traverse (loop through each letter) of the encrypted message and replace each occurrence of the correctly guessed encrypted letter with its corresponding clear text letter in upper-case. 2) Update the HTML label displaying the updated message. 3) Draw a happy animation in the canvas. When the player guesses incorrectly, your program must use the canvas to indicate its disappointment. 12 When the guess is invalid (one or both of the input fields is blank or contains a non-letter or an upper-case letter), your program must use the canvas to indicate its frustration. 6

Lab Requirements: Game Over When all the letters in the message are upper-case, then the message is fully decrypted and the player has won the game. Your program must recognize when this happens and display a happy animation in the canvas. There is not a requirement for a lose condition, however, if you want, you may add a maximum number of guesses after which if the player has not won, then he or she loses. Your program may, if you want, display the total number of guesses and/or a history of all guesses. 13 Lab Requirements: Game Instructions Your game must be uploaded to a website. Submit the URL to the game in Blackboard Learn. Your webpage must include instructions explaining how to play the game. Your website must have a logical layout when viewed in a reasonably sized browser window. Including text labels explaining input fields (for example: "Enter an encrypted letter here:"). Your page must include at lease one static.png or.jpg image - not in the canvas, just in the regular HTML as in the given example. 14 7

Grading Rubric: 20 Points Total [3 points]: When loaded, the website randomly chooses between at least 20 themed sentences. [5 points]: The website correctly displays an encrypted sentence with spaces and punctuation left clear text. [6 points]: When the player enters a correct guess, the website displays the sentence with the all correctly guessed letters replaced by upper-case clear text. [2 points]: When the player enters a correct guess a happy something displays in the canvas. [2 points]: When the player enters a incorrect guess or invalid values, an unhappy something is displayed on the canvas. 15 [2 points]: When the player wins, a happy animation is displayed in the canvas. JavaScript String Function: touppercase() JavaScript Strings have a function: touppercase() This returns a new string equal to the original string with all lower case letters converted to upper case. Example: var msg = "g"; msg = msg.touppercase(); console.log(msg); 16 8

JavaScript String's.charCodeAt(idx) var word = "a"; console.log(word + ": " + word.charcodeat(0)); word = "cat"; console.log(word + ": " + word.charcodeat(0)); 17 For a full list of ASCII codes see: http://www.ascii-code.com/ JavaScript String Function: replace(findstring, replacewithstring) JavaScript Strings have a function: replace(findstring, replacewithstring) This returns a new string equal to the original string with the first occurrence of findstring replaced by replacewithstring. Example: var msg = "t wcyaaym zb s aztq."; msg = msg.replace("a", "P"); console.log(msg); 18 t wcypaym zb s aztq. 9

replaceall helper Function: replaceall(str, findstr, replacewith) //============================================ // Returns a new string with all occurrences of findstr in str // replaced with replacewithstr. //============================================ function replaceall(str, findstr, replacewith) { while (str.indexof(findstr) >= 0) { str = str.replace(findstr, replacewith); } return str; } 19 20 isletter helper Function: isletter(str) //============================================ // Returns true if and only if the give string is a single, // lower-case letter. //============================================ function isletter(str) { if (str.length!= 1) return false; if (str.charcodeat(0) < 'a'.charcodeat(0)) { return false; } if (str.charcodeat(0) > 'z'.charcodeat(0)) { return false; } return true; } 10

How to Check a Player Guess Let guesspart1 be the character a player entered as the first part of a guess (the encrypted letter). Let guesspart2 be the character a player entered as the second part of a guess (the letter he or she things the encrypted letter represents in plain text). Then, use the map array to encrypt guesspart2. The guess is correct if and only if the result is equal to guesspart1. 21 Getting it to Work Break the assignment into small parts and get each part working before starting work on the next part. Place a colsole.log(string) at the start of every function. The string should include the name of the function and the value of its inputs (if it has inputs). Place a colsole.log(string) at after each complex calculation so you can see the result is what you think they should be. 22 11

Definitions The cypher is a bijection (a one-to-one onto map). The cardinality (size) of the bijection is 26 (the letters of the English alphabet). The letters to be encrypted form a well-ordered set (every non-empty subset of the set has a least element in this ordering). An ordinal denotes a position in a sequence ("first", "second", "third", etc.) of a well-ordered set. 23 The ordinal of a plaintext letter in the alphabet array is: (A=0, B=1, C=2,... Z=25). Quiz: What is the output? 24 1) a = []; 2) i = 2; 3) y = 16; 4) while (i < 20) 5) { a.push(i); 6) text(a, 5, y); 7) i = i * 3; 8) y = y + 16 9) } (a) 2 2,6 2,6,18 (b) (c) (d) (e) 2 2,6 2,6,9 2,6,9,12 2 2,6 2,6,9 2,6,9,12 2,6,9,12,15 2 2,6 2,6,9 2 2,6 2,6,9 2,6,9,12 2,6,9,12,15 2,6,9,12,15,18 12

25 Quiz: What is the output? 1) a = []; 2) i = 1; 3) y = 15; 4) while (i <= 20) 5) { a.push(i); 6) a.push(i); 7) text(a, 5, y); 8) i = i * 5; 9) y = y + 15 10)} 1 1,5 1,5,15 (a) (b) (c) (d) 1, 1 1, 1, 5, 5 a = [] [1, 1] [1, 1, 5, 5] i = 1 5 25 y = 15 30 45 1 1, 5 1, 5, 10 1, 5, 10, 15 1, 1 1, 1, 5, 5 1, 1, 5, 5 1, 1, 5, 5, 10, 10 (e) 1 1, 5 1, 5, 10 1, 5, 10, 15 1, 5, 10, 15, 20 13