← Back to all guides
Cybersecurity·Nov 27, 2021

Cryptography Basics: Encryption and Hashing

Cryptography can be separated into major categories including Asymmetric Encryption, Symmetric Encryption and Hashes. The article explains the categories with related examples and screen captures. Asymmetric and symmetric encryption Asymmetric encryption In terms of asymmetric encryption, different keys are used for encryption and decryption. The public key can be revealed to everyone. Therefore, it is

Cryptography can be separated into major categories including Asymmetric Encryption, Symmetric Encryption and Hashes. The article explains the categories with related examples and screen captures.

Asymmetric and symmetric encryption

Asymmetric encryption

In terms of asymmetric encryption, different keys are used for encryption and decryption. The public key can be revealed to everyone. Therefore, it is also known as public-key cryptography. With the public key provided by a receiver, a sender can use it to encrypt a message. The encrypted message can only be decrypted via a private key owned by the receiver.

Advantages: Does not face the key exchange problem – no need to pass a shared secret to both parties.

Disadvantages: Much slower than symmetric encryption – only suitable for exchanging a small amount of data.

Examples: RSA, ECC, PKI (Public Key Infrastructure)

Use cases: Digital certificates issued by a certificate authority

Illustration for Cryptography Basics: Encryption and Hashing
ECC Encryption Example – Web Certificate for noobquestions.com
Illustration for Cryptography Basics: Encryption and Hashing
RSA Encryption Example – Web Certificate for bing.com

Symmetric encryption

As for symmetric encryption, the same key is used for encryption and decryption. A key is used to encrypt a message and the same key can be used to decrypt it. As a result, it is also known as shared key encryption.

Advantages: Much faster than asymmetric encryption – can be used to exchange a large amount of data.

Disadvantages: The key exchange problem – passing a shared secret to both parties can be difficult. There is no way to secure a communication during the initial key exchange stage. In other words, a message can be intercepted during the initial key exchange over an insecure channel like the Internet.

Examples: AES

Use cases: File compression and decompression (ZIP), Streaming, Media Storage

Illustration for Cryptography Basics: Encryption and Hashing
AES Encryption Example – Compress File (ZIP)

Hashing

What is the difference between encryption and hashes?

Hashes is done one-way. If a message is hashed, it cannot be reversed. A unique hash is created for every message. In contrast, an encrypted message can be decrypted – the original content can be obtained if a message is encrypted rather than hashed.

Example: MD5, SHA

Use cases: File integrity check, password stored in a database and password comparison when logging in

Illustration for Cryptography Basics: Encryption and Hashing
Checksum Example
b3bb91ad96f2d4c041861ce59ba6ac73  w64/putty.exe
Illustration for Cryptography Basics: Encryption and Hashing
Password Hash Example (OpenCast software, password stored in MariaDB, using bcrypt password hashing algorithm)

Comments

0 comments

Ask a question or share a practical note. Comments appear immediately after passing the spam check.

Loading comments…

Be constructive and specific.