Intro to Computer Science CS1510

Slides:



Advertisements
Similar presentations
CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
Advertisements

 Caesar used to encrypt his messages using a very simple algorithm, which could be easily decrypted if you know the key.  He would take each letter.
Python Magic Select a Lesson: Why Learn to Code? Basic Python Syntax
CMPE13 Cyrus Bazeghi Hands on with Functions and IO.
4-6 3x3 Matrices, Determinants, & Inverses
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
CATHERINE AND ANNIE Python: Part 4. Strings  Strings are interesting creatures. Although words are strings, anything contained within a set of quotes.
Encryption: A Brief History Author: Margery Waldron.
Lab 07: Caesar Cypher Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Numerical Representation Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg 1.
CS1101: Programming Methodology Aaron Tan.
Lab 07: Caesar Cypher Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Computing Science 1P Large Group Tutorial: Lab Exam & Class Test Simon Gay Department of Computing Science University of Glasgow 2006/07.
Exam Prep and Wrap-Up Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Cryptology aka Cryptography Tim Cahill Ryan Church.
Problem Solving Intro to Computer Science CS1510 Dr. Sarah Diesburg 1.
Encryption. LEARNING OBJECTIVES: BY THE END OF THE LESSON YOU SHOULD KNOW. What encryption is and why it is important The basics of encryption techniques.
More String Manipulation. Programming Challenge Define a function that accepts two arguments: a string literal and a single character. Have the function.
Intelligent Data Systems Lab. Department of Computer Science & Engineering Practices 컴퓨터의 개념 및 실습 4 월 11 일.
 Type Called bool  Bool has only two possible values: True and False.
Copyright © 2013, 2009, 2005 Pearson Education, Inc. 1 4 Inverse, Exponential, and Logarithmic Functions Copyright © 2013, 2009, 2005 Pearson Education,
Encryption with Keys and Passwords
Vocabulary Big Data - “Big data is a broad term for datasets so large or complex that traditional data processing applications are inadequate.” Moore’s.
Whatcha doin'? Aims: To start using Python. To understand loops.
Introduction CS 303 Algorithmic Number Theory and Cryptography
Encryption.
Vocabulary Big Data - “Big data is a broad term for datasets so large or complex that traditional data processing applications are inadequate.” Moore’s.
Vocabulary Big Data - “Big data is a broad term for datasets so large or complex that traditional data processing applications are inadequate.” Moore’s.
Whatcha doin'? Aims: To understand the Caesar Cipher.
CMSC201 Computer Science I for Majors Lecture 13 – Midterm Review
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
CompSci 101 Introduction to Computer Science
Lesson 4-5 AP Computer Science Principles
Class 9 Reading and writing to files chr, ord and Unicode
Intro to Computer Science CS1510
Week 4 gur zntvp jbeqf ner fdhrnzvfu bffvsentr
User access levels, Passwords, Encryption, Cipher, Key
More Nested Loops and Lab 5
EYFS Curriculum Meeting
String Manipulation Part 2
String Encodings and Penny Math
Teaching London Computing
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Cryptography “The Secret Code Language”
Reactive Android Development
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
CSC 221: Introduction to Programming Fall 2018
Simple Encryption- Lesson 5
CS 1111 Introduction to Programming Fall 2018
Cryptography Cryptography is derived from the Green word ‘kryptos’
Data Structure and Algorithms
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Lesson 7: Simple Encryption
functions: argument, return value
How to use hash tables to solve olympiad problems
LONG MULTIPLICATION is just multiplying two numbers.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Introduction to Strings
Lists – Indexing and Sorting
CS150 Introduction to Computer Science 1
String Encodings and Penny Math
CS2911 Week 3, Lab Today Thursday Friday Review Muddiest Point Lab 3
More Strings.
Week of November 18-22, 2013 Warm-ups.
Double Transpositions
CMPT 120 Lecture 10 – Unit 2 – Cryptography and Encryption –
CMPT 120 Lecture 9 – Unit 2 – Cryptography and Encryption –
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Presentation transcript:

Intro to Computer Science CS1510 Lab 07: Caesar Cypher Intro to Computer Science CS1510

Caesar Cypher Method named after Julius Caesar Used in his private correspondence One of the simplest and most widely-known encryption techniques

Caesar Cypher We can start understanding the Caesar Cypher by writing out each letter of the alphabet

Caesar Cypher To encode, we apply a rotation value to the alphabet Before encoding with rotation of 3: “hello” After encoding (shift 3 to right): “khoor” After decoding (shift 3 to left): “hello”

Caesar Cypher Two ways to solve the problem Mathematically using ord() and chr() functions Create a shifted string, use the str.find() method

Mathematical Solution This solution hinges around knowing the ASCII/Unicode values of letters We only encode lowercase letters and leave all other letters the same

Mathematical Solution ‘z’=122 As we go through the string to encrypt, each ord() of each character must be >= 97 and <= 122 for us to apply a shift We then add the rotation value (say 3) to the ord() of each character to create a shifted character We can then take the chr() of the shifted character to get the encoded character

Mathematical Solution But what if shifting the character brings us beyond our bound of z? ord(y) + 3 = 124 chr(124) = “|” We must check that’s not the case by using an “if” statement if shiftedChar > 122: shiftedChar = shiftedChar - 26

Mathematical Solution Let’s create the solution

Shifted String Solution The other solution involves using two strings Alphabet Shifted alphabet, based on rotation value (say 3)

Shifted String Solution We can go through the string to be encoded character by character For each character, we use the str.find() method to get the index of the character in the regular alphabet origIndex = input.find(“h”) Is 7

Shifted String Solution Once we have the index of the character in the alphabet, we can look up what character is at that index in the shifted alphabet shiftedChar = shiftedAlphabet[7] Remember, origIndex = 7 shiftedChar is now “k”

Shifted String Solution Let’s create the solution

Cracking the Code We don’t know the rotation value, but we do know one word in the decoded string We need to start decoding with all possible rotation values, starting at 1 If we can find the one word we know in the decoded string, we are done Otherwise, we keep decoding with different rotation values (2,3,4,…)

Advice for the Tests These two things can make the difference of whether you pass or fail this class before taking the exams Go through each class days notes and example programs on the website Practice coding over and over!!! This is the only way to really learn. Review by reading the book!!

Advice for Tests In-class review on Monday In-class exam on Wednesday This is not a substitute for studying and practicing on your own In-class exam on Wednesday Closed book, closed notes Sabin 102 In-lab exam on Thursday Can use Python docs (from the IDLE help menu)

Test Location on Wednesday 102 Sabin Hall https://www.uni.edu/its/labs/computer-based- testing-center