Professional Documents
Culture Documents
Shift cipher
Share to Google Classroom Share Tweet
Email
XOR bitwise operation 1. Convert the letter into the number that matches
its order in the alphabet starting from 0, and call
XOR and the one-time this number X.
pad
( A=0, B=1, C=2, ...,Y=24, Z=25)
Practice: Bitwise
operators 2. Calculate: Y = (X + K) mod 26
Feedback
https://www.khanacademy.org/computing/computerscience/cryptography/ciphers/a/shiftcipher 1/10
11/24/2016 Shift cipher | Ciphers | Journey into cryptography | Computer science | Khan Academy
COMPUTER SCIENCE
INTO CRYPTOGRAPHY
JOURNEY
So, after applying the Shift Cipher with key K=19
our message text "KHAN" gave us cipher text
Ciphers
"DATG".
Shift cipher
How to decrypt:
XOR bitwise operation
For every letter in the cipher text C :
XOR and the one-time
pad 1. Convert the letter into the number that matches
its order in the alphabet starting from 0, and call
Practice: Bitwise
operators this number Y.
(A=0, B=1, C=2, ..., Y=24, Z=25)
Feedback
https://www.khanacademy.org/computing/computerscience/cryptography/ciphers/a/shiftcipher 2/10
11/24/2016 Shift cipher | Ciphers | Journey into cryptography | Computer science | Khan Academy
2. Calculate: X= (Y - K) mod 26
Next tutorial
Cryptography challenge …
3. Convert the number X into a letter that matches
its order in the alphabet starting from 0.
(A=0, B=1, C=2, ..., Y=24, Z=25)
Feedback
https://www.khanacademy.org/computing/computerscience/cryptography/ciphers/a/shiftcipher 3/10
11/24/2016 Shift cipher | Ciphers | Journey into cryptography | Computer science | Khan Academy
Ask a question...
Next tutorial
Cryptography challenge …
Questions Tips & Thanks Top Recent
https://www.khanacademy.org/computing/computerscience/cryptography/ciphers/a/shiftcipher 4/10
11/24/2016 Shift cipher | Ciphers | Journey into cryptography | Computer science | Khan Academy
Examples:
27 mod 26... 27 / 26 is 1 R 1, so 27 mod 26 is 1
53 mod 26... 53 / 26 is 2 R 1 so 53 mod 26 is also 1
10 mod 3 is also 1 (since 10 / 3 = 3 R 1)
2 mod 2 = 0
3 mod 2 = 1
4 mod 2 = 0
5 mod 2 = 1
6 mod 2 = 0
25 mod 26 = 25
50 mod 26 = 24
Practice: Bitwise
operators I just do this.
var a = x % y;
Feedback a += y;
a %= y;
https://www.khanacademy.org/computing/computerscience/cryptography/ciphers/a/shiftcipher 5/10
11/24/2016 Shift cipher | Ciphers | Journey into cryptography | Computer science | Khan Academy
Next tutorial Short and easy to write. I think it looks quite nice.
Cryptography challenge …
7 votes • 2 comments • Flag
3 years ago by Noble Mushtak
Shift cipher
Please explain "mod" for the examples.
https://www.khanacademy.org/computing/computerscience/cryptography/ciphers/a/shiftcipher 6/10
11/24/2016 Shift cipher | Ciphers | Journey into cryptography | Computer science | Khan Academy
Next tutorial
Cryptography challenge …
H e l l o K=1
7 4 16 16 19
6 3 15 15 18
+26 26 26 26 26?
-----------------------------
32 29 41 41 44
Those aren't even letters on the number to letter step.
Please help I'm confused.
1 vote • 1 comment • Flag 2 years ago by Andrea
https://www.khanacademy.org/computing/computerscience/cryptography/ciphers/a/shiftcipher 7/10
11/24/2016 Shift cipher | Ciphers | Journey into cryptography | Computer science | Khan Academy
Practice: Bitwise
operators Why we cannot comment also under the exercises or
games? It would be more convenient to discuss possible
setbacks right there, won´t it?
Feedback
2 votes • Comment • Flag 2 years ago by galvanek.m
https://www.khanacademy.org/computing/computerscience/cryptography/ciphers/a/shiftcipher 8/10
11/24/2016 Shift cipher | Ciphers | Journey into cryptography | Computer science | Khan Academy
Next tutorial
Cryptography challenge …
I have a feeling it might be to discourage people from
finding the answers they need in the comments. You
could click on the "request for features" link on the right
if you wanted to ask them though!
2 votes • Comment • Flag
2 years ago by jon.email
Ciphers
As per step 2:
2. Calculate: X= (Y - K) mod 26
Ciphers vs. codes (3-19)mod 26 = -16 mod 26 = 10
(0-19)mod 26 = -19 mod 26 = 7
(19-19)mod 26 = 0 mod 26= 0
Shift cipher (6-19 )mod 26 = -13 mod 26 = 13
See
https://www.khanacademy.org/computing/computer-
XOR bitwise operation
science/cryptography/modarithmetic/a/what-is-
modular-arithmetic
XOR and the one-time for more info on the mod operator
pad
3. Convert the number X into a letter that matches its
Practice: Bitwise order in the alphabet starting from 0.
operators (A=0, B=1, C=2, ..., Y=24, Z=25)
(Note letters start at 0)
10 maps to the 11th letter in the… (more)
Feedback
2 votes • Comment • Flag
https://www.khanacademy.org/computing/computerscience/cryptography/ciphers/a/shiftcipher 9/10
11/24/2016 Shift cipher | Ciphers | Journey into cryptography | Computer science | Khan Academy
Ciphers
Terms of Use Privacy Notice © 2016 Khan Academy
Except where noted, all rights reserved.
Ciphers vs. codes
Free classes and courses available for online learning at every level: Elementary, High school, and College lessons.
Shift cipher
Practice: Bitwise
operators
Feedback
https://www.khanacademy.org/computing/computerscience/cryptography/ciphers/a/shiftcipher 10/10