SlideShare a Scribd company logo
GANDHINAGAR INSTITUTE OF TECHNOLGY
Information Technology Department
Classical Cyphers
Presented By
Name: Shaishav Shah
8-IT-B1
Enrollment no: 170120116094
Guided By
Prof. Swapnil Panchal
Python Programming(2180703)
Classical Cypher
• Classical cryptography and stenography are very fun to
program. They are often used in various capture the flag
programmer events. Classical substitution ciphers, like Caesar
Cipher, are particularly fun, because they are simple enough to
understand and crack with just a little bit of knowledge. One
can often find puzzles, called Cryptograms or Cryptoquotes, in
newspapers or online that challenge the user to figure out a
popular phrase given the ciphertext version of it.
Cryptography
• Cryptography deals with encrypting or encoding a piece of
information (in a plain text) into a form that looks gibberish and
makes little sense in ordinary language.
• This encoded message(also called ciphertext) can then be
decoded back into a plain text by the intended recipient using a
decoding technique (often along with a private key)
communicated to the end-user.
Caesar cypher
• Although Caesar Cipher is a very weak encryption
technique and is rarely used today, we are doing this tutorial
to introduce our readers, especially the newcomers, to
encryption.
• Caesar Cipher is a type of substitution, in which each letter in
the plain text is replaced by another letter at some fixed
positions from the current letter in the alphabet.
• For example, if we shift each letter by three positions to the
right, each of the letters in our plain text will be replaced by a
letter at three positions to the right of the letter in the plain
text.
• Let us see this in action – let’s encrypt the text “HELLO
WORLD” using a right shift of 3.
• So the letter H will be replaced by K, E will be replaced by H,
and so on. The final encrypted message for HELLO
WORLD will be KHOOR ZRUOG.
• Note that the letters on edge i.e., X, Y, Z wrap around and are
replaced by A, B, C respectively, in case of the right shift.
Similarly, the letters in the beginning – A, B, C, etc. will be
wrapped around in case of left shifts.
• The Caesar Cipher encryption rule can be expressed
mathematically as:
•
c= (x+n) %26
• Where c is the encoded character, x is the actual character, and
n is the number of positions we want to shift the character x
by. We’re taking mod with 26 because there are 26 letters in
the English alphabet.
Caesar Cipher in Python
• Caesar Cipher in Python, we’ll first look at two important
functions that we’ll use extensively during the process –
chr() and ord().
It is important to realize that the alphabet as we know them, is
stored differently in a computer’s memory. The computer
doesn’t understand any of our English language’s alphabet or
other characters by itself.
• Each of these characters is represented in computer memory
using a number called ASCII code (or its extension – the
Unicode) of the character, which is an 8-bit number and
encodes almost all the English language’s characters, digits,
and punctuations.
For instance, the uppercase ‘A’ is represented by the number
65, ‘B’ by 66, and so on. Similarly, lowercase characters’
representation begins with the number 97.
• As the need to incorporate more symbols and characters of
other languages arose, the 8 bit was not sufficient, so a new
standard – Unicode – was adopted, which represents all the
characters used in the world using 16 bits.
• ASCII is a subset of Unicode, so the ASCII encoding of
characters remains the same in Unicode. That means ‘A’ will
still be represented using the number 65 in Unicode.
Note that the special characters like space ” “, tabs “t”,
newlines “n”, etc. are also represented in memory by their
Unicode.
The ord() function
• You can use the ord() method to convert a character to its
numeric representation in Unicode. It accepts a single character
and returns the number representing its Unicode. Let’s look at
an example.
The chr() function
• Just like how we could convert a character into its numeric
Unicode using ord() method, we do the inverse i.e., find the
character represented by a number using chr() method.
The chr() method accepts a number representing the Unicode of a
character and returns the actual character corresponding to the
numeric code.
Let’s first look at a few examples:
•
• Notice how the German letter Ü (U umlaut) is also
represented in Unicode by the number 360.
• We can also apply a chained operation(ord followed by
chr) to get the original character back.
Encryption for Capital Letters
1. Define the shift value i.e., the number of positions we want to
shift from each character.
2. Iterate over each character of the plain text:
1. If the character is upper-case:
1.Calculate the position/index of the character in the 0-25
range.
2.Perform the positive shift using the modulo operation.
3.Find the character at the new position.
4.Replace the current capital letter by this new character.
2. Else, If the character is not upper-case, keep it with no
change.
Decryption for Capital Letters
• Now that we’ve figured out the encryption for plain text capital
letters using Ceaser Cipher let’s look at how we will decrypt the
ciphertext into plain text.
• Earlier, we looked at the mathematic formulation of the
encryption process. Let’s now check out the same for the
decryption process.
• X= (c-n ) % 26
• The meaning of the notations remains the same as in the
previous formula.
If any value becomes negative after subtraction, the modulo
operator will take care of that, and it will wrap it around.
• Let us look at the step-by-step implementation of the decryption
process, which will be more or less the reverse of the
encryption:
• Define the number of shifts
• Iterate over each character in the encrypted text:
• If the character is an uppercase letter:
• Calculate the position/index of the character in the 0-25
range.
• Perform the negative shift using the modulo operation.
• Find the character at the new position.
• Replace the current encrypted letter by this new character
(which will also be an uppercase letter).
• Else, if the character is not capital, keep it unchanged.
Thank You...!!!

More Related Content

What's hot

Strings
StringsStrings
Strings
Nilesh Dalvi
 
M.Sridevi II-M.Sc (computer science)
M.Sridevi II-M.Sc (computer science)M.Sridevi II-M.Sc (computer science)
M.Sridevi II-M.Sc (computer science)
SrideviM4
 
Operation on string presentation
Operation on string presentationOperation on string presentation
Operation on string presentation
Aliul Kadir Akib
 
String c
String cString c
05 c++-strings
05 c++-strings05 c++-strings
05 c++-strings
Kelly Swanson
 
Network Security-UNIT -II(Classical Encription) -Sridevi.M-II-M.Sc.,Computer ...
Network Security-UNIT -II(Classical Encription) -Sridevi.M-II-M.Sc.,Computer ...Network Security-UNIT -II(Classical Encription) -Sridevi.M-II-M.Sc.,Computer ...
Network Security-UNIT -II(Classical Encription) -Sridevi.M-II-M.Sc.,Computer ...
SrideviM4
 
Source coding
Source coding Source coding
Source coding
Shankar Gangaju
 
Strings
StringsStrings
Strings
Mitali Chugh
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
Tasnima Hamid
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
anithabalaprabhu
 
Secure Encyrption Systems Chapter 2
Secure Encyrption Systems Chapter 2Secure Encyrption Systems Chapter 2
Secure Encyrption Systems Chapter 2
AfiqEfendy Zaen
 
Strings
StringsStrings
Strings in c
Strings in cStrings in c
Strings in c
vampugani
 
string in C
string in Cstring in C
C++ string
C++ stringC++ string
C++ string
Dheenadayalan18
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
SaranyaK68
 
Huffman Algorithm and its Application by Ekansh Agarwal
Huffman Algorithm and its Application by Ekansh AgarwalHuffman Algorithm and its Application by Ekansh Agarwal
Huffman Algorithm and its Application by Ekansh Agarwal
Ekansh Agarwal
 
Huffman and Arithmetic coding - Performance analysis
Huffman and Arithmetic coding - Performance analysisHuffman and Arithmetic coding - Performance analysis
Huffman and Arithmetic coding - Performance analysis
Ramakant Soni
 
COm1407: Character & Strings
COm1407: Character & StringsCOm1407: Character & Strings
COm1407: Character & Strings
Hemantha Kulathilake
 
Strings
StringsStrings
Strings
Imad Ali
 

What's hot (20)

Strings
StringsStrings
Strings
 
M.Sridevi II-M.Sc (computer science)
M.Sridevi II-M.Sc (computer science)M.Sridevi II-M.Sc (computer science)
M.Sridevi II-M.Sc (computer science)
 
Operation on string presentation
Operation on string presentationOperation on string presentation
Operation on string presentation
 
String c
String cString c
String c
 
05 c++-strings
05 c++-strings05 c++-strings
05 c++-strings
 
Network Security-UNIT -II(Classical Encription) -Sridevi.M-II-M.Sc.,Computer ...
Network Security-UNIT -II(Classical Encription) -Sridevi.M-II-M.Sc.,Computer ...Network Security-UNIT -II(Classical Encription) -Sridevi.M-II-M.Sc.,Computer ...
Network Security-UNIT -II(Classical Encription) -Sridevi.M-II-M.Sc.,Computer ...
 
Source coding
Source coding Source coding
Source coding
 
Strings
StringsStrings
Strings
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
Secure Encyrption Systems Chapter 2
Secure Encyrption Systems Chapter 2Secure Encyrption Systems Chapter 2
Secure Encyrption Systems Chapter 2
 
Strings
StringsStrings
Strings
 
Strings in c
Strings in cStrings in c
Strings in c
 
string in C
string in Cstring in C
string in C
 
C++ string
C++ stringC++ string
C++ string
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Huffman Algorithm and its Application by Ekansh Agarwal
Huffman Algorithm and its Application by Ekansh AgarwalHuffman Algorithm and its Application by Ekansh Agarwal
Huffman Algorithm and its Application by Ekansh Agarwal
 
Huffman and Arithmetic coding - Performance analysis
Huffman and Arithmetic coding - Performance analysisHuffman and Arithmetic coding - Performance analysis
Huffman and Arithmetic coding - Performance analysis
 
COm1407: Character & Strings
COm1407: Character & StringsCOm1407: Character & Strings
COm1407: Character & Strings
 
Strings
StringsStrings
Strings
 

Similar to Classical cyphers python programming

security Symmetric Key Cryptography Substitution Cipher, Transposition Cipher.
security Symmetric Key Cryptography Substitution Cipher, Transposition Cipher.security Symmetric Key Cryptography Substitution Cipher, Transposition Cipher.
security Symmetric Key Cryptography Substitution Cipher, Transposition Cipher.
nagwaAboElenein
 
Symmetric and asymmetric key cryptography
Symmetric and asymmetric key cryptographySymmetric and asymmetric key cryptography
Symmetric and asymmetric key cryptography
MONIRUL ISLAM
 
Caesar Cipher , Substitution Cipher, PlayFair and Vigenere Cipher
Caesar Cipher , Substitution Cipher, PlayFair and Vigenere CipherCaesar Cipher , Substitution Cipher, PlayFair and Vigenere Cipher
Caesar Cipher , Substitution Cipher, PlayFair and Vigenere Cipher
Mona Rajput
 
Secret key cryptography
Secret key cryptographySecret key cryptography
Secret key cryptography
Prabhat Goel
 
Cryptography
CryptographyCryptography
Cryptography
Iama Marsian
 
Classical encryption techniques
Classical encryption techniquesClassical encryption techniques
Classical encryption techniques
Dr.Florence Dayana
 
cryptography.ppt
cryptography.pptcryptography.ppt
cryptography.ppt
AkshayaPriyaJanartha
 
Cryptography CET 2.pptx
Cryptography CET 2.pptxCryptography CET 2.pptx
Cryptography CET 2.pptx
jhonmacchony
 
IS_Classical-Encryption-Techniques_5.pdf
IS_Classical-Encryption-Techniques_5.pdfIS_Classical-Encryption-Techniques_5.pdf
IS_Classical-Encryption-Techniques_5.pdf
RameezRaja32147
 
Cryptography
CryptographyCryptography
Cryptography
Jens Patel
 
Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
ShilpaShettyA1
 
Computer Network Unit-5 (Part-1).pdf
Computer Network Unit-5 (Part-1).pdfComputer Network Unit-5 (Part-1).pdf
Computer Network Unit-5 (Part-1).pdf
ParshantYadav13
 
Information security (Symmetric encryption, cryptography, crypto-analysis)
Information security (Symmetric encryption, cryptography, crypto-analysis)Information security (Symmetric encryption, cryptography, crypto-analysis)
Information security (Symmetric encryption, cryptography, crypto-analysis)
Zara Nawaz
 
Symmetric Encryption Techniques
Symmetric Encryption Techniques Symmetric Encryption Techniques
Symmetric Encryption Techniques
Dr. Kapil Gupta
 
Unit – III.pptx
Unit – III.pptxUnit – III.pptx
Unit – III.pptx
PriyankaPawar57960
 
Encrypted message transmitter on public network
Encrypted message transmitter on public networkEncrypted message transmitter on public network
Encrypted message transmitter on public network
Rowshina Nikzad
 
Encryption is a process of converting a message, image, or any other .pdf
 Encryption is a process of converting a message, image, or any other .pdf Encryption is a process of converting a message, image, or any other .pdf
Encryption is a process of converting a message, image, or any other .pdf
rachanaprade
 
Cryptography using python
Cryptography using pythonCryptography using python
Cryptography using python
KaushikRamabhotla
 
Understanding the History of EncryptionUnderstanding the
Understanding the History of EncryptionUnderstanding theUnderstanding the History of EncryptionUnderstanding the
Understanding the History of EncryptionUnderstanding the
corbing9ttj
 
Information Security Cryptography ( L03- Old Cryptography Algorithms )
Information Security Cryptography ( L03- Old Cryptography Algorithms )Information Security Cryptography ( L03- Old Cryptography Algorithms )
Information Security Cryptography ( L03- Old Cryptography Algorithms )
Anas Rock
 

Similar to Classical cyphers python programming (20)

security Symmetric Key Cryptography Substitution Cipher, Transposition Cipher.
security Symmetric Key Cryptography Substitution Cipher, Transposition Cipher.security Symmetric Key Cryptography Substitution Cipher, Transposition Cipher.
security Symmetric Key Cryptography Substitution Cipher, Transposition Cipher.
 
Symmetric and asymmetric key cryptography
Symmetric and asymmetric key cryptographySymmetric and asymmetric key cryptography
Symmetric and asymmetric key cryptography
 
Caesar Cipher , Substitution Cipher, PlayFair and Vigenere Cipher
Caesar Cipher , Substitution Cipher, PlayFair and Vigenere CipherCaesar Cipher , Substitution Cipher, PlayFair and Vigenere Cipher
Caesar Cipher , Substitution Cipher, PlayFair and Vigenere Cipher
 
Secret key cryptography
Secret key cryptographySecret key cryptography
Secret key cryptography
 
Cryptography
CryptographyCryptography
Cryptography
 
Classical encryption techniques
Classical encryption techniquesClassical encryption techniques
Classical encryption techniques
 
cryptography.ppt
cryptography.pptcryptography.ppt
cryptography.ppt
 
Cryptography CET 2.pptx
Cryptography CET 2.pptxCryptography CET 2.pptx
Cryptography CET 2.pptx
 
IS_Classical-Encryption-Techniques_5.pdf
IS_Classical-Encryption-Techniques_5.pdfIS_Classical-Encryption-Techniques_5.pdf
IS_Classical-Encryption-Techniques_5.pdf
 
Cryptography
CryptographyCryptography
Cryptography
 
Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
 
Computer Network Unit-5 (Part-1).pdf
Computer Network Unit-5 (Part-1).pdfComputer Network Unit-5 (Part-1).pdf
Computer Network Unit-5 (Part-1).pdf
 
Information security (Symmetric encryption, cryptography, crypto-analysis)
Information security (Symmetric encryption, cryptography, crypto-analysis)Information security (Symmetric encryption, cryptography, crypto-analysis)
Information security (Symmetric encryption, cryptography, crypto-analysis)
 
Symmetric Encryption Techniques
Symmetric Encryption Techniques Symmetric Encryption Techniques
Symmetric Encryption Techniques
 
Unit – III.pptx
Unit – III.pptxUnit – III.pptx
Unit – III.pptx
 
Encrypted message transmitter on public network
Encrypted message transmitter on public networkEncrypted message transmitter on public network
Encrypted message transmitter on public network
 
Encryption is a process of converting a message, image, or any other .pdf
 Encryption is a process of converting a message, image, or any other .pdf Encryption is a process of converting a message, image, or any other .pdf
Encryption is a process of converting a message, image, or any other .pdf
 
Cryptography using python
Cryptography using pythonCryptography using python
Cryptography using python
 
Understanding the History of EncryptionUnderstanding the
Understanding the History of EncryptionUnderstanding theUnderstanding the History of EncryptionUnderstanding the
Understanding the History of EncryptionUnderstanding the
 
Information Security Cryptography ( L03- Old Cryptography Algorithms )
Information Security Cryptography ( L03- Old Cryptography Algorithms )Information Security Cryptography ( L03- Old Cryptography Algorithms )
Information Security Cryptography ( L03- Old Cryptography Algorithms )
 

More from ShaishavShah8

Diffie hellman key algorithm
Diffie hellman key algorithmDiffie hellman key algorithm
Diffie hellman key algorithm
ShaishavShah8
 
Constructor oopj
Constructor oopjConstructor oopj
Constructor oopj
ShaishavShah8
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
ShaishavShah8
 
Classification of debuggers sp
Classification of debuggers spClassification of debuggers sp
Classification of debuggers sp
ShaishavShah8
 
Parallel and perspective projection in 3 d cg
Parallel and perspective projection in 3 d cgParallel and perspective projection in 3 d cg
Parallel and perspective projection in 3 d cg
ShaishavShah8
 
Asymptotic notations ada
Asymptotic notations adaAsymptotic notations ada
Asymptotic notations ada
ShaishavShah8
 
Arrays in java oopj
Arrays in java oopjArrays in java oopj
Arrays in java oopj
ShaishavShah8
 
Logics for non monotonic reasoning-ai
Logics for non monotonic reasoning-aiLogics for non monotonic reasoning-ai
Logics for non monotonic reasoning-ai
ShaishavShah8
 
Rdd transformations bda
Rdd transformations bdaRdd transformations bda
Rdd transformations bda
ShaishavShah8
 
Introduction to data warehouse dmbi
Introduction to data warehouse dmbiIntroduction to data warehouse dmbi
Introduction to data warehouse dmbi
ShaishavShah8
 
Lan, wan, man mcwc
Lan, wan, man mcwcLan, wan, man mcwc
Lan, wan, man mcwc
ShaishavShah8
 
Introduction to xml, uses of xml wt
Introduction to xml, uses of xml wtIntroduction to xml, uses of xml wt
Introduction to xml, uses of xml wt
ShaishavShah8
 
Agile process se
Agile process seAgile process se
Agile process se
ShaishavShah8
 
Applications of huffman coding dcdr
Applications of huffman coding dcdrApplications of huffman coding dcdr
Applications of huffman coding dcdr
ShaishavShah8
 
Cookie management using jsp a java
Cookie management using jsp  a javaCookie management using jsp  a java
Cookie management using jsp a java
ShaishavShah8
 
Login control .net
Login control .netLogin control .net
Login control .net
ShaishavShah8
 
Rdd transformations
Rdd transformationsRdd transformations
Rdd transformations
ShaishavShah8
 
LAN, WAN, MAN
LAN, WAN, MANLAN, WAN, MAN
LAN, WAN, MAN
ShaishavShah8
 
Introduction to data warehouse
Introduction to data warehouseIntroduction to data warehouse
Introduction to data warehouse
ShaishavShah8
 

More from ShaishavShah8 (19)

Diffie hellman key algorithm
Diffie hellman key algorithmDiffie hellman key algorithm
Diffie hellman key algorithm
 
Constructor oopj
Constructor oopjConstructor oopj
Constructor oopj
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
Classification of debuggers sp
Classification of debuggers spClassification of debuggers sp
Classification of debuggers sp
 
Parallel and perspective projection in 3 d cg
Parallel and perspective projection in 3 d cgParallel and perspective projection in 3 d cg
Parallel and perspective projection in 3 d cg
 
Asymptotic notations ada
Asymptotic notations adaAsymptotic notations ada
Asymptotic notations ada
 
Arrays in java oopj
Arrays in java oopjArrays in java oopj
Arrays in java oopj
 
Logics for non monotonic reasoning-ai
Logics for non monotonic reasoning-aiLogics for non monotonic reasoning-ai
Logics for non monotonic reasoning-ai
 
Rdd transformations bda
Rdd transformations bdaRdd transformations bda
Rdd transformations bda
 
Introduction to data warehouse dmbi
Introduction to data warehouse dmbiIntroduction to data warehouse dmbi
Introduction to data warehouse dmbi
 
Lan, wan, man mcwc
Lan, wan, man mcwcLan, wan, man mcwc
Lan, wan, man mcwc
 
Introduction to xml, uses of xml wt
Introduction to xml, uses of xml wtIntroduction to xml, uses of xml wt
Introduction to xml, uses of xml wt
 
Agile process se
Agile process seAgile process se
Agile process se
 
Applications of huffman coding dcdr
Applications of huffman coding dcdrApplications of huffman coding dcdr
Applications of huffman coding dcdr
 
Cookie management using jsp a java
Cookie management using jsp  a javaCookie management using jsp  a java
Cookie management using jsp a java
 
Login control .net
Login control .netLogin control .net
Login control .net
 
Rdd transformations
Rdd transformationsRdd transformations
Rdd transformations
 
LAN, WAN, MAN
LAN, WAN, MANLAN, WAN, MAN
LAN, WAN, MAN
 
Introduction to data warehouse
Introduction to data warehouseIntroduction to data warehouse
Introduction to data warehouse
 

Recently uploaded

GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 

Recently uploaded (20)

GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 

Classical cyphers python programming

  • 1. GANDHINAGAR INSTITUTE OF TECHNOLGY Information Technology Department Classical Cyphers Presented By Name: Shaishav Shah 8-IT-B1 Enrollment no: 170120116094 Guided By Prof. Swapnil Panchal Python Programming(2180703)
  • 2. Classical Cypher • Classical cryptography and stenography are very fun to program. They are often used in various capture the flag programmer events. Classical substitution ciphers, like Caesar Cipher, are particularly fun, because they are simple enough to understand and crack with just a little bit of knowledge. One can often find puzzles, called Cryptograms or Cryptoquotes, in newspapers or online that challenge the user to figure out a popular phrase given the ciphertext version of it.
  • 3. Cryptography • Cryptography deals with encrypting or encoding a piece of information (in a plain text) into a form that looks gibberish and makes little sense in ordinary language. • This encoded message(also called ciphertext) can then be decoded back into a plain text by the intended recipient using a decoding technique (often along with a private key) communicated to the end-user.
  • 4. Caesar cypher • Although Caesar Cipher is a very weak encryption technique and is rarely used today, we are doing this tutorial to introduce our readers, especially the newcomers, to encryption. • Caesar Cipher is a type of substitution, in which each letter in the plain text is replaced by another letter at some fixed positions from the current letter in the alphabet. • For example, if we shift each letter by three positions to the right, each of the letters in our plain text will be replaced by a letter at three positions to the right of the letter in the plain text. • Let us see this in action – let’s encrypt the text “HELLO WORLD” using a right shift of 3.
  • 5.
  • 6. • So the letter H will be replaced by K, E will be replaced by H, and so on. The final encrypted message for HELLO WORLD will be KHOOR ZRUOG. • Note that the letters on edge i.e., X, Y, Z wrap around and are replaced by A, B, C respectively, in case of the right shift. Similarly, the letters in the beginning – A, B, C, etc. will be wrapped around in case of left shifts. • The Caesar Cipher encryption rule can be expressed mathematically as: • c= (x+n) %26 • Where c is the encoded character, x is the actual character, and n is the number of positions we want to shift the character x by. We’re taking mod with 26 because there are 26 letters in the English alphabet.
  • 7. Caesar Cipher in Python • Caesar Cipher in Python, we’ll first look at two important functions that we’ll use extensively during the process – chr() and ord(). It is important to realize that the alphabet as we know them, is stored differently in a computer’s memory. The computer doesn’t understand any of our English language’s alphabet or other characters by itself.
  • 8. • Each of these characters is represented in computer memory using a number called ASCII code (or its extension – the Unicode) of the character, which is an 8-bit number and encodes almost all the English language’s characters, digits, and punctuations. For instance, the uppercase ‘A’ is represented by the number 65, ‘B’ by 66, and so on. Similarly, lowercase characters’ representation begins with the number 97. • As the need to incorporate more symbols and characters of other languages arose, the 8 bit was not sufficient, so a new standard – Unicode – was adopted, which represents all the characters used in the world using 16 bits. • ASCII is a subset of Unicode, so the ASCII encoding of characters remains the same in Unicode. That means ‘A’ will still be represented using the number 65 in Unicode. Note that the special characters like space ” “, tabs “t”, newlines “n”, etc. are also represented in memory by their Unicode.
  • 9. The ord() function • You can use the ord() method to convert a character to its numeric representation in Unicode. It accepts a single character and returns the number representing its Unicode. Let’s look at an example.
  • 10. The chr() function • Just like how we could convert a character into its numeric Unicode using ord() method, we do the inverse i.e., find the character represented by a number using chr() method. The chr() method accepts a number representing the Unicode of a character and returns the actual character corresponding to the numeric code. Let’s first look at a few examples: •
  • 11. • Notice how the German letter Ü (U umlaut) is also represented in Unicode by the number 360. • We can also apply a chained operation(ord followed by chr) to get the original character back.
  • 12. Encryption for Capital Letters 1. Define the shift value i.e., the number of positions we want to shift from each character. 2. Iterate over each character of the plain text: 1. If the character is upper-case: 1.Calculate the position/index of the character in the 0-25 range. 2.Perform the positive shift using the modulo operation. 3.Find the character at the new position. 4.Replace the current capital letter by this new character. 2. Else, If the character is not upper-case, keep it with no change.
  • 13. Decryption for Capital Letters • Now that we’ve figured out the encryption for plain text capital letters using Ceaser Cipher let’s look at how we will decrypt the ciphertext into plain text. • Earlier, we looked at the mathematic formulation of the encryption process. Let’s now check out the same for the decryption process. • X= (c-n ) % 26 • The meaning of the notations remains the same as in the previous formula. If any value becomes negative after subtraction, the modulo operator will take care of that, and it will wrap it around.
  • 14. • Let us look at the step-by-step implementation of the decryption process, which will be more or less the reverse of the encryption: • Define the number of shifts • Iterate over each character in the encrypted text: • If the character is an uppercase letter: • Calculate the position/index of the character in the 0-25 range. • Perform the negative shift using the modulo operation. • Find the character at the new position. • Replace the current encrypted letter by this new character (which will also be an uppercase letter). • Else, if the character is not capital, keep it unchanged.