String X=“Python Rocks!” X.index(“O”).

Slides:



Advertisements
Similar presentations
Mathematical Functions, Strings, and Objects. Introduction ■ To solve mathematics problems by using the functions in the math module (§3.2). ■ To represent.
Advertisements

Computer Science 101 Data Encryption And Computer Networks.
Team Name: team13 Programmer: 陳則凱 b Tester: 劉典恆 b
 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
An Introduction to Cryptography TEA fellows February 9, 2012 Dr. Kristen Abernathy.
Cryptography 101 How is data actually secured. RSA Public Key Encryption RSA – names after the inventors –Rivest, Shamir, and Adleman Basic Idea: Your.
Cryptography Introduction, continued. Sufficient key space principle If an encryption scheme has a key space that is too small, then it will be vulnerable.
Computer Science 111 Fundamentals of Programming I Sequences: Strings.
2.1.4 BINARY ASCII CHARACTER SETS A451: COMPUTER SYSTEMS AND PROGRAMMING.
Introduction to Computing Using Python More Built-in Container Classes  Container Class dict  Encoding of String Characters  Randomness and Random Sampling.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#6)
Introduction to Computing Using Python Chapter 6  Encoding of String Characters  Randomness and Random Sampling.
Introduction to Computing Using Python More Built-in Container Classes  Container Class dict  Container Class set  Container Class tuple  Encoding.
Cryptography Programming Lab
It is pronounced ‘askee’
Hands on Projects Dr. Bernard Chen Ph.D. University of Central Arkansas July 9 th 2012
Chapter 2 – Elementary Cryptography  Concepts of encryption  Cryptanalysis  Symmetric (secret key) Encryption (DES & AES)(DES & AES)  Asymmetric (public.
Systems of Equations as Matrices and Hill Cipher.
Team Name: team13 Programmer: 陳則凱 b Tester: 劉典恆 b
Computer Security coursework 2 Dr Alexei Vernitski.
More on Functions (Part 2) Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Day 18. Concepts Plaintext: the original message Ciphertext: the transformed message Encryption: transformation of plaintext into ciphertext Decryption:
An Introduction to Cryptography. What is cryptography? noun \krip- ˈ tä-grə-fē\ : the process of writing or reading secret messages or codes “Encryption”:
Elementary Cryptography  Concepts of encryption  Symmetric (secret key) Encryption (DES & AES)(DES & AES)  Asymmetric (public key) Encryption (RSA)(RSA)
Python Programming in Context Chapter 3. Objectives To introduce the string data type To demonstrate the use of string methods and operators To introduce.
Encryption. What is Encryption? Encryption is the process of converting plain text into cipher text, with the goal of making the text unreadable.
Computing Science 1P Large Group Tutorial: Lab Exam & Class Test Simon Gay Department of Computing Science University of Glasgow 2006/07.
MAT 1000 Mathematics in Today's World Winter 2015.
Encryption CS110: Computer Science and the Internet.
Introduction to Cryptography Lecture 8. Polyalphabetic Substitutions Definition: Let be different substitution ciphers. Then to encrypt the message apply.
Validation final steps Stopping gaps being entered in an input.
If/else, return, user input, strings
Some of these PowerPoint pages were created by my friend Shawna Haider.
More String Manipulation. Programming Challenge Define a function that accepts two arguments: a string literal and a single character. Have the function.
Substitution Ciphers Reference –Matt Bishop, Computer Security, Addison Wesley, 2003.
Department of Computer Science Chapter 5 Introduction to Cryptography Semester 1.
LAB#3 CLASSICAL ENCRYPTION CPIT 425. This diagram is taken from Dr.Omaima slides.
Design of Rock-Paper-Scissors end Print instructions Play game Ask user If (s)he wants to play again Play again? Y Print stats: wins, losses and ties start.
Intelligent Data Systems Lab. Department of Computer Science & Engineering Practices 컴퓨터의 개념 및 실습 4 월 11 일.
Print the sample banner slides or customize with your own message. Click on the letter and type your own text. Use one character per slide. C.
Unit 2.6 Data Representation Lesson 2 ‒ Characters
Encryption.
Adapted from slides by Marty Stepp and Stuart Reges
Breaking the Code Can anyone guess the phrase from this “code”?
Representing Characters
CSc 110, Spring 2017 Lecture 11: while Loops, Fencepost Loops, and Sentinel Loops Adapted from slides by Marty Stepp and Stuart Reges.
W Customize this banner with your own message! Select the letter and add your own text. Use one character per slide.
String Encodings and Penny Math
B Customize this banner with your own message! Select the letter and add your own text. Use one character per slide.
Adapted from slides by Marty Stepp and Stuart Reges
CSc 110, Spring 2018 Lecture 14: Booleans and Strings
Higher Computing Using Loops.
H Customize this banner with your own message! Select the letter and add your own text. Use one character per slide.
CSC 221: Introduction to Programming Fall 2018
B Customize this banner with your own message! Select the letter and add your own text. Use one character per slide.
Simple Encryption- Lesson 5
Class Examples.
Adapted from slides by Marty Stepp and Stuart Reges
W Customize this banner with your own message! Select the letter and add your own text. Use one character per slide.
H Customize this banner with your own message! Select the letter and add your own text. Use one character per slide.
W Customize this banner with your own message! Select the letter and add your own text. Use one character per slide.
functions: argument, return value
W Customize this banner with your own message! Select the letter and add your own text. Use one character per slide.
String Encodings and Penny Math
Hint idea 2 Split into shorter tasks like this.
Running Key Cipher The security of polyalphabetic substitution cipher reside in key length. In running-key cipher, the length of key must be equal the.
W Customize this banner with your own message! Select the letter and add your own text. Use one character per slide.
W Customize this banner with your own message! Select the letter and add your own text. Use one character per slide.
H Customize this banner with your own message! Select the letter and add your own text. Use one character per slide.
Presentation transcript:

String X=“Python Rocks!” X.index(“O”)

Character Encoding ASCII code A – 65; B – 66; … ; Z – 90 http://www.asciitable.com/ >>> ord(‘A’) # ASCII value or order of letter >>> chr(65) # opposite of ord()

Cryptography Encoding and Decoding Messages

Translation Cipher Replace each character by ord(character)+constant A B C D E F …. X Y Z 0 1 2 3 4 5 …. 23 24 25 +5 5 6 7 8 9 10 … 26 or over -> wrap around

EncoderDecoder.py (p.99) message = input(“Enter a message to encode: \n”) message = message.upper() # make all uppercase cipher = “” for letter in message: if letter.isupper(): val = ord(letter)+13 newlet = chr(val) if not newlet.isupper(): newlet = chr(val-26) cipher = cipher + newlet print(“Cipher text: “, cipher)

Update with Modulo Function EncoderDecoder.py Update with Modulo Function message = input(“Enter a message to encode: \n”) message = message.upper() cipher = “” for letter in message: if letter.isupper(): val = ord(letter)+13 newlet = chr(val) if not newlet.isupper(): newlet = chr(val-26) cipher = cipher + newlet print(“Cipher text: “, cipher) message = input(“Enter a message to encode: \n”) message = message.upper() cipher = “” for letter in message: cipher = cipher + newlet print(“Cipher text: “, cipher)

Encryption Key

Vigenere Square

A Card Game Computer draws a card for me and one for you Wins whichever has a higher face value

HighCard.py (p. 125) import random faces = [“two”,”three”,”four”,”five”,”six”,”seven”,”eight”,”nine”,”ten”,”jack”,”queen”,”kin g”,”ace”] keep_going=1 while keep_going>0: my_face = random.choice(faces) your_face = random.choice(faces) if faces.index(my_face) > faces.index(your_face): print (“I win!”) elif faces.index(my_face)<faces.index(your_face): print(“You win!”) else: print(“A tie!”) keep_going=eval(input(“Enter 0 to stop, 1 to continue”))

HW 3 Due next Wed (10/14) 10:00 AM Do two problems Chap. 5 #2: User-defined keys (p. 102) Instead of constant 13 to translate, use a number a user enters in the keyboard Use the modulo operator to replace a letter by a cipher letter Chap. 6 #3: War Email two programs to 2015fall91.100@gmail.com