- Foundation
- About 13 min
- 5 practice questions
Encryption, hashing and digital signatures
Describe plain text and cipher text, tell symmetric from asymmetric keys, and explain hashing and digital signatures.
If something looks wrong, please tell us.
Encryption is the science behind most online safety: padlocks in browsers, secure messaging and safe payments all rest on it. You do not need mathematics to understand the ideas, only a clear picture of who holds which key.
Basic words
- Plain text: the readable original message.
- Cipher text: the scrambled message after encryption.
- Encryption: turning plain text into cipher text using a key.
- Decryption: turning cipher text back into plain text using a key.
- Key: a secret value that controls the scrambling. Without the correct key the cipher text should be useless.
A very simple example is the Caesar cipher, in which each letter is shifted by a fixed number of places. With a shift of 3, the word CAT becomes FDW. It is easy to break, but it shows the idea of a method plus a key.
Symmetric and asymmetric encryption
| Type | Keys used | Strength | Weak point |
|---|---|---|---|
| Symmetric | One shared secret key to lock and unlock | Fast, good for large data | Sender and receiver must share the key safely |
| Asymmetric (public key) | A pair: public key and private key | No need to share a secret in advance | Slower than symmetric |
In asymmetric encryption, the public key can be given to anyone, while the private key is kept secret by its owner. If someone encrypts a message with your public key, only your private key can open it. Real systems often combine both kinds: asymmetric encryption to agree on a key safely, then symmetric encryption for the bulk of the data.
Hashing
A hash function turns any data into a short fixed-size string called a hash or digest. The same input always gives the same hash, but even a tiny change in the input gives a completely different hash, and you cannot work backwards from the hash to the original data. Hashing is therefore not encryption: it cannot be decrypted. Websites store the hash of your password rather than the password itself, and compare hashes when you log in. Hashes are also used to check that a downloaded file has not been altered.
Digital signatures and certificates
A digital signature proves who sent a document and that it was not changed. The sender creates it with their private key, and anyone can check it with the sender's public key. It gives authenticity and integrity. A digital certificate, issued by a trusted body called a Certificate Authority, links a public key to a named person or website, and browsers use certificates when they set up HTTPS.
Worked examples
Example 1. Using the Caesar cipher with a shift of 3, encrypt BAG. Shift each letter three places forward: B becomes E, A becomes D, G becomes J. The cipher text is EDJ. To decrypt, shift each letter three places back.
Example 2. Asha wants to send Ravi a message that only Ravi can read. Which key should she use to encrypt? Ravi's public key. Only Ravi's private key can decrypt it.
Example 3. A website stores the hash of your password. A hacker steals the database. Why is it better than storing plain passwords? The hash cannot simply be reversed, so the hacker does not directly see the passwords. This is one reason why weak, common passwords are still risky, since an attacker can hash guesses and compare them.
Encryption can be reversed with the key. Hashing cannot be reversed. Signatures use the private key to sign and the public key to check.
Key takeaways
- Symmetric encryption uses one shared key; asymmetric uses a public and private pair.
- Hashing is one-way and is used for checking, not for hiding messages for later reading.
- A digital signature gives authenticity and integrity.
- Certificates connect public keys to real identities.
Check your understanding
-
1. Turning plain text into cipher text is called
- Encryption
- Decryption
- Hashing only
- Formatting
Show answer
Answer: A. Encryption scrambles readable plain text into cipher text using a key; decryption does the reverse.
-
2. In public-key (asymmetric) encryption, a message encrypted with Ravi's public key can be opened with
- Asha's public key
- Any public key
- No key at all
- Ravi's private key
Show answer
Answer: D. The two keys form a pair. What the public key locks, only the matching private key can unlock.
-
3. Which statement about hashing is correct?
- A hash can be decrypted with a key
- A hash is the same length as the original file
- A hash is a one-way fixed-size summary of data
- Hashing needs two keys
Show answer
Answer: C. A hash function is one-way and gives a fixed-size output. It cannot be decrypted.
-
4. A digital signature is created using the sender's
- Private key
- Public key
- Email password
- Router password
Show answer
Answer: A. The sender signs with a private key, and receivers check it with the matching public key.
-
5. Using a shift of 2 in a Caesar cipher, the word DOG becomes
- BME
- FQI
- EPH
- GRJ
Show answer
Answer: B. Shift each letter two places forward: D to F, O to Q, G to I. So DOG becomes FQI.
Sign in to keep track of the lessons you finish.