Introduction to Cryptography I: Encryption (Pt. 1 - The Caesar Cipher)

in #steemstem6 years ago (edited)

Hey friends! @lemony-cricket here, and even though cryptography is the stuff that powers our collective rocket lambo ride to the moon... encryption has absolutely nothing to do with that. That's it. End of post. You can stop reading now.

This is the first post in this series. The next post is here.



Rocket graphic extracted from this CC0 image from OpenClipart-Vectors on Pixabay.

But I want to understand... please teach me.

Fair enough. In this series (of which this is the inaugural post), I will attempt to teach the beginner about the basic building blocks of cryptography. Note that this series is not about cryptocurrency, but about the field of computer and information science known as cryptography. But despair not, dear reader, because learning about cryptography now will actually help you understand better how cryptocurrency works, if that's your thing! I will probably do a series on that too, after this one.

We are starting from the ground up here. I'll stress beginner again. If you cringed at the title, knowing full well what a Caesar cipher is and wondering why it's being mentioned in this millenium, you might get a little bored with this post. If so, come back in a few posts when we should be getting into more modern encryption.


The Caesar Cipher

a brief introduction to the concept of encryption

The first occurrences of what we today call 𝕖𝕟𝕔𝕣𝕪𝕡𝕥𝕚𝕠𝕟d1 utilised the group of 𝕒𝕝𝕘𝕠𝕣𝕚𝕥𝕙𝕞𝕤d2 we now know as classical ciphers. There are a few different types of classical ciphers, all of which are no longer useful in the Information Age. They do, however, provide an interesting bit of history, as well as an easy way to exemplify the concept of encryption.

The most famous classical cipher is most likely the Caesar cipher, which you might have guessed was used by the Roman dictator Julius Caesar. Also known as the shift cipher, this algorithm is extremely simple and can be performed using only a pencil and paper (or even your favourite word processor!).

The shift cipher worked much better when nobody really knew what it was. It's distant history today. But what I would like to do, is use is as an example to introduce some words and concepts you'll need to know for future installments.

Now, together, let's encrypt a message, by hand, using the shift cipher.


Interactive exercise

You should have paper and something to write with for this portion.

First, let's write down the English alphabet. Write it in a straight line, like shown below:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Next, pick a number from 1 to 23. This number will be your 𝕜𝕖𝕪d3. As an example, I'm going to use a 𝕣𝕠𝕥𝟙𝟛d4 cipher, which means my key is 13. Starting with A as zero, count forward in the alphabet to your key, and write A beneath the letter you end up on:

0 1 2 3 4 5 6 7 8 9 0 1 2 3
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
                          A 

Now fill in the rest of the alphabet. When you get to the end, wrap around to below the A and keep going. Be sure to keep the letters lined up neatly! Leave some space between them or draw lines between the columns to distinguish them.

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
N O P Q R S T U V W X Y Z A B C D E F G H I J K L M

Write a message down on the paper. It should consist only of the 26 letters above, no punctuation. This message is your 𝕡𝕝𝕒𝕚𝕟𝕥𝕖𝕩𝕥d4. Here's an example:

I WANT A RUSTY AXE

For each letter in your plaintext, find that letter on the top line above, and write down the letter directly beneath it. For instance, for I we would write V, for W we would write J, and so on:

V JNAG N EHFGL NKR

We did it! What I have just done, and what you've done too if you've been following along, is technically encryption (albeit a very unsafe variety!).

Now, we can prove it worked by reversing the process: find each letter of the 𝕔𝕚𝕡𝕙𝕖𝕣𝕥𝕖𝕩𝕥d5 in the bottom row and replace it with the letter immediately above it. You should end up with the original message again:

I WANT A RUSTY AXE

At this point, you've not only done encryption, but you've performed a 𝕕𝕖𝕔𝕣𝕪𝕡𝕥𝕚𝕠𝕟d6 operation as well! We're on a roll!

Here's your chance for an upvote if you're paying attention. Think of a short message you'd like to give me. Pick your own key and message; don't use mine! Then encrypt it with a shift cipher using the steps above, and send your ciphertext in the comments. I like a challenge, so don't tell me what the key is! 🍋


Definitions

From my personal knowledge and experience unless otherwise noted.

  1. encryption: the act of transforming data in a reversible way in order to hide information from others.
  2. algorithm: a specific process with a strict set of rules which, when applied, generates some desired result. There are algorithms for every kind of problem a computer can solve. A cipher is a type of algorithm, used for encryption.
  3. key: a secret that is used along with the cipher algorithm. In general, algorithms do not change, but keys do. The "13" part of the rot13 example above is the key.
  4. rot13: a specific Caesar cipher using a shift of 13, so that the encrypt and decrypt operations are functionally the same algorithm with the standard English alphabet (since 13 is half of 26).
  5. plaintext: the actual message or data; this is the thing you are trying to hide by encrypting.
  6. ciphertext: the encrypted message or data; the output of the cipher. If your cipher is secure (shift ciphers are not secure!), this is what is safe to send over the Internet, store in public places, etc.
Sort:  

Hello yellowy boy! :) QUHN U LOMNS URY!
I have a message for you:
EYYJ OJ NBY AIIX QILE
Cheers :)

Nbuhem; C qcff nls! C bijy sio qcff dich om zil zonoly fymmihm!

text btvmt xlm

Xm mn, utvanlebu?

PDEOE OEJOW JA!YHK SJLKO OA

Wjz w heppha oel kb Bwuck pkk... ;)

Cvdfep tiplf jtyffc wfi effsj

Nzcc pfl sv afzezex lj wfi wlkliv cvjjfej? ^_^

K VJKPM AQW CTG C DGCWVKHWN KFGC

Vjcpm aqw @mgz; K vjkpm aqw ctg dgcwvkhwn vqq! ^_^ Rngcug eqog dcem pgzv vkog!!!

Gur jvaavat ybggb ahzoref ner

jryy, ner lbh tbvat gb gryy zr?

AVAR

What taught me encryption when it comes to computers was researching how to encrypt passwords securely and learning to encrypt my hard drive. It worked pretty well. I highly suggest it. :P

Your post made me realize I did learn a lot about basic cryptography for fun as a child though. Tolkien and Poe both taught me a bit as well.

I see what you did there. Just sayin'.

What can I say? It was stuck in my head. The lyric. Not the axe.

Is encryption harder to crack than the power of an inside joke?

I have a feeling you were saying this to be funny, which it was, but I also have a way of looking past that and ruining the joke by taking things seriously! So let's get to it then!

That's a damned good question, and hard to answer! It depends on what kind of encryption we're talking about (the one we learned about today is very weak), and the complexity and "inside-ness" of the inside joke.

Assuming the "inside-ness" is high, we may be looking at something that is information-theoretically secure, which would mean that the inside joke is the clear winner.

However, our axe joke is probably not! A sufficiently advanced AI algorithm could pick up on the "I see what you did there" and look for certain bits of information in my post. It might then happen upon the lyric, and through statistical analysis of our mutual YouTube traffic, it may find this video:

And make the connection. That would be some voodoo indeed... but it is plausible.

I didn't know I wanted to learn about these concepts before today. I suppose we will soon be talking about how the crypto in cryptocurrencies works, right? (that would be dope)

Glad you're enjoying it. The next part will be about a more advanced type of encryption. Believe it or not, encryption is not actually used by cryptocurrencies! They use other cryptographic concepts such as digital signatures and hash functions. I will definitely be talking about those later on in the series! Stay tuned!

Thank you!! I had that confusion for way too long. I am sort of new to this world, and I am very eager to continue reading you!

I am forcing myself to learn all I can about coding, cryptocurrencies, etc... Posts like this one are helpful

Hi @lemony-cricket!

Your post was upvoted by utopian.io in cooperation with steemstem - supporting knowledge, innovation and technological advancement on the Steem Blockchain.

Contribute to Open Source with utopian.io

Learn how to contribute on our website and join the new open source economy.

Want to chat? Join the Utopian Community on Discord https://discord.gg/h52nFrV

Coin Marketplace

STEEM 0.30
TRX 0.11
JST 0.033
BTC 64271.38
ETH 3157.43
USDT 1.00
SBD 4.25