Cryptography#
In this notebook on Cryptography, we will explore the foundations of secure communication through two major tools: hashing and encryption. Hashing is a one-way function used primarily for data verification, while encryption involves transforming data so only authorized parties can access it. We’ll dive into both symmetric encryption, where the same key is used for both encryption and decryption, and asymmetric encryption (like RSA), where different keys are used.
Cryptography is essential for enforcing the core principles of information security. Authentication ensures that users and systems are who they claim to be, often supported by cryptographic signatures or challenge-response mechanisms. Non-repudiation guarantees that a sender cannot deny sending a message, which is made possible through digital signatures and public-key infrastructure. Confidentiality protects data from unauthorized access using encryption, so only intended recipients can read the content. Finally, integrity ensures that data has not been altered, often verified through cryptographic hash functions. These principles form the backbone of secure systems, and cryptography makes them possible.
Hashing#
With hashing, we’ll start with some data, pass that data through a hash function that then returns a fixed-length value based upon the hash algorithm.

Hash algorithms need to exhibit these properties:
Deterministic: same input → same hash
Fast: efficient to compute
Preimage Resistance: hard to reverse
Collision Resistance: unlikely to find two inputs with the same hash
Avalanche Effect: small input change → very different output
Python has a built-in library to support hashing: hashlib https://docs.python.org/3/library/hashlib.html
SHA1/2: https://csrc.nist.gov/pubs/fips/180-4/upd1/final
SHA3: https://csrc.nist.gov/pubs/fips/202/final
1import hashlib
2
3print ("Available hash algorithms: ", hashlib.algorithms_guaranteed, end ="")
Available hash algorithms: {'sha3_224', 'shake_256', 'sha384', 'shake_128', 'sha3_384', 'sha1', 'md5', 'sha3_256', 'sha256', 'sha512', 'blake2b', 'blake2s', 'sha224', 'sha3_512'}
1str_to_hash = "Financial Technology"
2
3# printing the equivalent hexadecimal value.
4print(" SHA1:", hashlib.sha1(str_to_hash.encode()).hexdigest())
5print(" SHA256:", hashlib.sha256(str_to_hash.encode()).hexdigest())
6print(" SHA384:", hashlib.sha384(str_to_hash.encode()).hexdigest())
7print(" SHA512:", hashlib.sha512(str_to_hash.encode()).hexdigest())
8print("SHA3_512:", hashlib.sha3_512(str_to_hash.encode()).hexdigest())
SHA1: b82ec64123fa89c827a3628232027d2325a04a05
SHA256: dbff121dfbf46ae5735169fa0f4e4c5756d8d4fcc25d5dfc03302c4046172c3c
SHA384: 0639a713d0e58048d709de6625b8bb691313a21e13de86a3fc89fa04c2a4aab63e9312530593cb3c8a6e642fc207e748
SHA512: 71cf13861013ffe5206ef3d1a6b52321615d92f5144c652a5318402ad9b9ab5275cedc22abcfe9a8f0cc22e2e10be6e22edfe71a779600ee17dd5bd05c0c47da
SHA3_512: d08c519f77b5cfe5829f9f8328bce36b3dfdae5de13f36735bdaec58829c910e402c84a5f5aa12b546bdd6599f91d7d03f8fe5f5fad0c5b0c2b7c73d945def05
1str_to_hash = "Financial Technologz"
2
3# printing the equivalent hexadecimal value.
4print(" SHA1:", hashlib.sha1(str_to_hash.encode()).hexdigest())
5print(" SHA256:", hashlib.sha256(str_to_hash.encode()).hexdigest())
6print(" SHA384:", hashlib.sha384(str_to_hash.encode()).hexdigest())
7print(" SHA512:", hashlib.sha512(str_to_hash.encode()).hexdigest())
8print("SHA3_512:", hashlib.sha3_512(str_to_hash.encode()).hexdigest())
SHA1: 5ef54bf1964941566bc6aabba6d69d2f10f67310
SHA256: 3f447cba1a66a3acf4012e1c137d01ff76c405727f7e6194280c460fac361bbb
SHA384: 8a5c39bacbaa8016bf4e5e8b0982958ee044b28db8c61e7c944fed6ff6edf8cd60d9f23b7cfd514174555ab1d1ab2513
SHA512: fcf5d7b50124b5cdfbf5167cf0882d9fdebbc7cc76296708ffe88b0347aeee743df43a74a40c3c750ee35e63fc8b916466b99ffc82564a11626e8e164d5512a7
SHA3_512: 7f8e6b177461c487c745c5da6a064761c28c7d204e1259f9c2ae9e0a99ebda699787f4b8c8153cc1efb253988008b2e0fbf3137c486a61d404a8e424aae264e3
Hashing a File#
In hashing a file, we’ll need to read the file in “chunks” and update the hash object with that “chunk”.
Once all of the data has been read, then we can call digest() to produce the hash value.
1import hashlib
2import base64
3
4def hash_file_sha256(filepath):
5 """
6 Computes the SHA-256 hash of the specified file.
7
8 :param filepath: Path to the file to be hashed
9 :return: Hexadecimal SHA-256 hash string
10 """
11 sha256_hash = hashlib.sha256()
12 try:
13 with open(filepath, "rb") as f:
14 # Read and update hash in chunks to handle large files
15 for byte_block in iter(lambda: f.read(4096), b""):
16 sha256_hash.update(byte_block)
17 return sha256_hash.digest()
18 except FileNotFoundError:
19 print(f"File not found: {filepath}")
20 return None
21 except Exception as e:
22 print(f"An error occurred: {e}")
23 return None
1hash = hash_file_sha256("Mocking.ipynb")
2print(hash.hex())
3print(base64.b64encode(hash).decode("utf-8"))
fa3125814cbe04b10a4e00b00cdbd80b05e3e1dc15f275146f03c5e05da26b8e
+jElgUy+BLEKTgCwDNvYCwXj4dwV8nUUbwPF4F2ia44=
Password Hashing with Salts:#
The following image illustrates how password hashing with salting works in two main phases: Password Creation and Password Verification. In the Password Creation phase (left side), a user’s plaintext password is combined with a randomly generated salt. This combination is passed through a hashing process to produce a unique hash. Both the salt and the resulting hash are then stored. In the Password Verification phase (right side), when a user attempts to log in, the system takes the entered plaintext password and retrieves the stored salt. These are run through the same hashing process, and the resulting hash is compared to the stored hash. If they match, the password is correct. This method enhances security by preventing attackers from using precomputed hash databases (like rainbow tables), since the salt ensures that even identical passwords produce different hashes.

Note: the Flask tutorials uses library methods defined in werkzeug.security - https://werkzeug.palletsprojects.com/en/3.0.x/utils/#werkzeug.security.generate_password_hash. This builds upon the salt approach, but also adds an interation count to hash x times to increase the computation cost.
More iterations = deliberate slowness = stronger defense
It’s all about making life hard for attackers without making it noticeably slow for real users.
1# Source: https://stackoverflow.com/questions/9594125/salt-and-hash-a-password-in-python
2
3from typing import Tuple
4import os
5import hashlib
6import hmac
7import base64
8
9def hash_new_password(password: str) -> Tuple[bytes, bytes]:
10 """
11 Hash the provided password with a randomly-generated salt and return the
12 salt and hash to store in the database.
13 """
14 salt = os.urandom(16)
15 pw_hash = hashlib.pbkdf2_hmac('sha256', password.encode(), salt, 1000000)
16 return salt, pw_hash
17
18def is_correct_password(salt: bytes, pw_hash: bytes, password: str) -> bool:
19 """
20 Given a previously-stored salt and hash, and a password provided by a user
21 trying to log in, check whether the password is correct.
22 """
23 return hmac.compare_digest(
24 pw_hash,
25 hashlib.pbkdf2_hmac('sha256', password.encode(), salt, 1000000)
26 )
27
28# Example usage:
29salt, pw_hash = hash_new_password('correct horse battery staple')
30print(base64.b64encode(salt))
31print(base64.b64encode(pw_hash))
32print(salt.hex())
33print(pw_hash.hex())
34assert is_correct_password(salt, pw_hash, 'correct horse battery staple')
35assert not is_correct_password(salt, pw_hash, 'Tr0ub4dor&3')
36assert not is_correct_password(salt, pw_hash, 'rosebud')
b'72P/Vwgpr5jlEDLBV6dIBA=='
b'vbLHXpyhYEQmJn6HExIW5Fj5vr6pRxUj6I2Kh0wXWpk='
ef63ff570829af98e51032c157a74804
bdb2c75e9ca1604426267e87131216e458f9bebea9471523e88d8a874c175a99
Why “correct horse battery staple”? https://xkcd.com/936/
Encryption#
Encryption is like turning your message into a secret code that only the right person can read.
Imagine you want to send a message to a friend, like “Meet me at 5 PM.” If anyone else sees it, they’ll know your plans. But if you scramble the message in a special way — and only your friend knows how to unscramble it — then it stays private. That’s encryption!
How It Works (In Simple Terms)#

You have a message (called plaintext).
You run it through a special math formula (an encryption algorithm).
You use a key — kind of like a password — to lock or scramble the message.
The result is unreadable gibberish (called ciphertext).
Only someone with the right key can run it through the formula in reverse and read the original message again. That process is called decryption.
Why Do We Use Encryption?#
Privacy: Keeps your data safe from hackers and snoops.
Security: Protects things like online banking, passwords, and messages.
Trust: Makes sure no one tampered with your information along the way.
Real-Life Examples#
When you use WhatsApp or Signal, your messages are encrypted.
Websites that start with https:// use encryption to protect your connection.
Your phone and laptop often encrypt your data in case they get lost or stolen.
Pycryptodome#
PyCryptodome is a powerful Python library designed to bring cryptographic capabilities into your applications easily and securely. The package provides industry-standard tools for encryption, decryption, hashing, digital signatures, and more — all essential for protecting sensitive financial data like user credentials, transaction records, and API communications. PyCryptodome is a self-contained library, meaning it doesn’t rely on external dependencies, making it both secure and easy to integrate into modern Python-based fintech applications.
1%pip install pycryptodome
Requirement already satisfied: pycryptodome in /Users/jbslanka/Documents/GitHub/jupyternotebooks/venv/lib/python3.11/site-packages (3.22.0)
Note: you may need to restart the kernel to use updated packages.
Symmetric Encryption#
Symmetric encryption is a type of encryption where the same key is used to both encrypt and decrypt data. It’s fast, efficient, and commonly used to protect large amounts of data in applications like secure file storage, network communication, and payment systems. One of the most widely used symmetric encryption algorithms is AES (Advanced Encryption Standard). AES is trusted for its strong security and performance, making it a go-to choice for encrypting sensitive information in both commercial and government systems. However, because both parties must share the same secret key, securely exchanging and managing that key is a critical part of using symmetric encryption safely.
This code demonstrates how to securely encrypt and decrypt data using the AES (Advanced Encryption Standard) algorithm with the PyCryptodome library.
A couple of items to highlight:
Tag: an authentication code that ensures the data hasn’t been tampered with during transmission or storage. It’s generated during encryption and later verified during decryption. If someone tries to modify the ciphertext, the tag won’t match during verification, and decryption will fail. This provides integrity and authenticity — not just secrecy.
Nonce: The nonce (short for “number used once”) is a random or unique value used during encryption to ensure that the same plaintext encrypted multiple times produces different ciphertexts. This protects against pattern analysis and replay attacks. In GCM mode, using a unique nonce for each encryption is critical for security.
1from Crypto.Cipher import AES
2from Crypto.Random import get_random_bytes
3
4key = get_random_bytes(16)
1data = b'This is a long message that we can encrypt'
2
3cipher = AES.new(key, AES.MODE_GCM)
4ciphertext, tag = cipher.encrypt_and_digest(data)
5nonce = cipher.nonce
6
7print(ciphertext.hex())
8
9cipher = AES.new(key, AES.MODE_GCM, nonce)
10decrypted_data = cipher.decrypt_and_verify(ciphertext, tag)
11print(decrypted_data)
8750b519b5cc7355a64b5932fe8f085cc6519fb835f31ae7f629739d44373f4873960b81eae90768a110
b'This is a long message that we can encrypt'
Public Key / Assymetric Encryption#
Asymmetric encryption, also known as public-key encryption, uses a pair of keys: a public key for encryption and a private key for decryption. Unlike symmetric encryption, the keys are not the same — and the private key is kept secret while the public key can be shared openly. One of the most common asymmetric algorithms is RSA (Rivest–Shamir–Adleman). It’s widely used for securely exchanging data, verifying digital signatures, and establishing encrypted connections (like HTTPS). The main advantage of asymmetric encryption is that it eliminates the need to share a secret key ahead of time, making it ideal for secure communication over open networks. However, it’s slower than symmetric encryption, so it’s often used alongside algorithms like AES in hybrid encryption systems.

1from Crypto.PublicKey import RSA
2from Crypto.Cipher import PKCS1_OAEP
3from Crypto.Random import get_random_bytes
4
5# 1. Generate RSA Key Pair
6key = RSA.generate(2048)
7private_key = key.export_key()
8public_key = key.publickey().export_key()
9
10print("Private Key:")
11print(private_key.decode())
12print("\nPublic Key:")
13print(public_key.decode())
14
15key_bytes = key.export_key(format='OpenSSH')
16print("OpenSSH Public Key:")
17print(key_bytes.decode())
18
19# 2. Encrypt a message using the public key
20message = b'This is a secret message.'
21recipient_key = RSA.import_key(public_key)
22cipher_rsa = PKCS1_OAEP.new(recipient_key)
23encrypted_message = cipher_rsa.encrypt(message)
24
25print("\nEncrypted Message:")
26print(encrypted_message.hex())
27
28# 3. Decrypt the message using the private key
29private_key_obj = RSA.import_key(private_key)
30cipher_rsa = PKCS1_OAEP.new(private_key_obj)
31decrypted_message = cipher_rsa.decrypt(encrypted_message)
32
33print("\nDecrypted Message:")
34print(decrypted_message.decode())
Private Key:
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAmy7JTwx9s16ZbJfx5BqFCQcEZVlCP+MpcASdGQ10ceSi7yV1
sQhaXtVUvTG648fs/TUTJkyS1+aLopXP3y3wSLYf9GtNQ7zaFIMpr/9tolIUv+1T
tcpNZzzK5erfFuND6a2VegJ9/4RBxunsKW9llxNn1qJrTizr88BQVDdR7AN1M0E/
jkCBk4SC0UnRhMxqoqiDfc7AOlDbXEPriT2RngzgwaJse93IuOxbJMnyUb2cPtil
bFWnOt804bTc/Vv1fIjfqkY5CnE+kpYMuWVJzMHIoCEB56eXFY2F9Ux3CkRlq5lT
Ik4pnSkFikcSbx3x2goLVFT6oK5S02h+f30zswIDAQABAoIBAA72pvcWKqf5TwZk
OTEYLlkD5TRrAL/HHr+SolDzgpWM4pOR/O3YjIyo03Mro9LDYqKHBwhIllkQZC+5
DgJ+NbVwYlc5YlaBLYiQas+lHwqc3l7w+oM4AgvnYvhilA2eVakahNeIyZXlSEmi
IS4ppxXqcbcF+FGuDgTcawjqQKsAnLOwP/xZ+d/0uDxWYvxdqqB5WklFFf2rB7CC
zB9wBov2wvwxK/tDVZZzQhs0Ga3LgsKkWjE3QoFIw3X8bm9wbW6+YLqfvyczAz20
l2Q3t7+M5Mk4tjXyBsBeaSIL6yloK07A+UJ2M/0BEzozDFVjp6gKOcpZsH7WlUcd
hnFyvZkCgYEAwg3UteeDgO0Y7weJX7AfpIBd194Abe+jl7OWqxEt/LWE28pqbRms
WPUFKRBy9LtQiIkGBHydyt8XDrct0OxrGyotnLpmUzDR0Ttt2B4UVZxrnjd95gCz
RR86o2L4zLN7Qlnlci8nZS46tTRJ51DFi6f0gxqW4/Q8Dx2vx9bGfMUCgYEAzLhh
cWj0Jusy2OFDT9QU0hIWpAge6wRVh3FijLlTKVBQYoFszLQ0j9mVESqewUvna2aG
Cepu/okBLnkGP4ssdvWi6bWPqhE+n1NCN5qlvjfpCKi6d0ImPbDsW5bgyUqzRBQs
KTXegNRj34EB97GC2h2fhla4ZBdsJIuhn9hD5hcCgYAnQ/8vk5oDY3ZxH3hHmW69
rY/Pl0dE94GFt7wb/0zr3pr0kl+4lcJO+b1CkuZ/6Msh5YAHNmQDYeLbgmtN5BjE
FWPHW9xKpw09piXS3jtFG3KXQClEeg3MRcZquyMW4JZnVaNc2HfDPHh6pAr0OF7Q
pHqQcLfphkkE0f/4ktf09QKBgGEquoVbrVazl8S81ngTT3aNw1VDzXj666WHuaDV
bZVUW3MFvyBCABiuy0QEmKliX4rodIJMVTZWzMrEAqUyZ35nBFYtKO0tli2FFQ7T
RgvM+bx0aVyldwUc7nJiYHrqC8AqWvOMb/lx1Z2F2+s2w8bG/KqEiqxnOZr281Wt
Dj0tAoGABdn2BXA2tOJH0GU3pzAEBEoClnZ/qb82TrjYSVBJn5wEaLOcxTivcyUf
/NeXjtkUzal0wQv7Og2lLyqu/pKgrcUyidYpIQPFgWhQiYI5gs3j/tqQcVyoz8xF
Ke+GNmkv19fg1+AaSn4ZNArkAXiQ87XgVkNKICMncg9wOKdWQEs=
-----END RSA PRIVATE KEY-----
Public Key:
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmy7JTwx9s16ZbJfx5BqF
CQcEZVlCP+MpcASdGQ10ceSi7yV1sQhaXtVUvTG648fs/TUTJkyS1+aLopXP3y3w
SLYf9GtNQ7zaFIMpr/9tolIUv+1TtcpNZzzK5erfFuND6a2VegJ9/4RBxunsKW9l
lxNn1qJrTizr88BQVDdR7AN1M0E/jkCBk4SC0UnRhMxqoqiDfc7AOlDbXEPriT2R
ngzgwaJse93IuOxbJMnyUb2cPtilbFWnOt804bTc/Vv1fIjfqkY5CnE+kpYMuWVJ
zMHIoCEB56eXFY2F9Ux3CkRlq5lTIk4pnSkFikcSbx3x2goLVFT6oK5S02h+f30z
swIDAQAB
-----END PUBLIC KEY-----
OpenSSH Public Key:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCbLslPDH2zXplsl/HkGoUJBwRlWUI/4ylwBJ0ZDXRx5KLvJXWxCFpe1VS9Mbrjx+z9NRMmTJLX5ouilc/fLfBIth/0a01DvNoUgymv/22iUhS/7VO1yk1nPMrl6t8W40PprZV6An3/hEHG6ewpb2WXE2fWomtOLOvzwFBUN1HsA3UzQT+OQIGThILRSdGEzGqiqIN9zsA6UNtcQ+uJPZGeDODBomx73ci47FskyfJRvZw+2KVsVac63zThtNz9W/V8iN+qRjkKcT6Slgy5ZUnMwcigIQHnp5cVjYX1THcKRGWrmVMiTimdKQWKRxJvHfHaCgtUVPqgrlLTaH5/fTOz
Encrypted Message:
64d737e2607e1181b030215fa3d0730f4dd9ef1658491bf79e948d94871b72bc70575c93fca02f3d9e914228a03edba9ff9678c8967cbe5afa0286c37cc5e3d63bac24ce44032900c05bf80152924b7e16249637940f847fa2351c8981071bcfcf88e02b0ea79618c09d1f9f907ea3ef09b38ae556309238a3daf661194b131513b2d800fd1c09cefd2da2aba01a726e434b00d9f7fe9ae9fab4063620cbbab8e5c4dfd89325922125b65884ed0be74682aa0af013778706d674e91d99f0f9610c7cb7d6cddb69fffb9f62753953480a7382979bf317e6c239f6ebafcfa9e14a242bc315fdaa437785f52c16e8472a228c51f440e77db92e57688ae33bf76bb4
Decrypted Message:
This is a secret message.
Digital Signatures#
The following image explains how digital signatures work to ensure the authenticity and integrity of data. First, Mary creates a hash of her original document using a hash algorithm. She then encrypts this hash using her private key, creating a digital signature. The signed document is sent over the network. When James receives the document, he uses Mary’s public key to decrypt the signature and retrieve the original hash. He also generates a new hash from the received document using the same hash algorithm. If both hashes match, James can be confident that the document is authentic and has not been altered — and that it was indeed signed by Mary, since only her private key could have created a signature that matches her public key. This process ensures data integrity, authenticity, and non-repudiation in digital communications.

Image Source: https://www.webnic.cc/cyber-security/understand-what-is-a-digital-signature-and-its-benefits/
1from Crypto.PublicKey import RSA
2from Crypto.Signature import PKCS1_v1_5
3from Crypto.Hash import SHA256
4from Crypto import Random
5
6def generate_key_pair():
7 # Generate RSA key pair
8 random_generator = Random.new().read
9 key = RSA.generate(2048, random_generator)
10 return key
11
12def sign_message(private_key, message):
13 # Generate hash of the message
14 hash = SHA256.new(message.encode('utf-8'))
15 # Create a signer using the private key
16 signer = PKCS1_v1_5.new(private_key)
17 # Sign the hash
18 signature = signer.sign(hash)
19 return signature
20
21def verify_signature(public_key, message, signature):
22 # Generate hash of the message
23 hash = SHA256.new(message.encode('utf-8'))
24 # Create a verifier using the public key
25 verifier = PKCS1_v1_5.new(public_key)
26 # Verify the signature
27 return verifier.verify(hash, signature)
28
29# Generate key pair
30key_pair = generate_key_pair()
31private_key = key_pair.export_key()
32public_key = key_pair.publickey().export_key()
33
34# Example message
35message = "Hello, this is a test message."
36
37# Sign the message
38signature = sign_message(RSA.import_key(private_key), message)
39
40# Verify the signature
41verified = verify_signature(RSA.import_key(public_key), message, signature)
42
43print("Original message:", message)
44print("Signature:", signature)
45print("Verified:", verified)
Original message: Hello, this is a test message.
Signature: b"W\x1f\xaaQ\xe8\xa8\x94\xaaD{\xa2\x11\xa4\xa6D\xbdD\x0e\x1b\xbdCT\x0b\x0c\x8cS\x03b&c\x8f$\x88\x96\x1ec\x1fjg\xc7w\xaf_\xa1\xb5\xdc\xc9\xb7\x9c\xa5\xa4\x1e:\xc4%\xc3\xd3dem\xb3\x1d\x903\xbd\xa6\xc6#\xc3~\xe7\xaa6\xa5l\xa7\xe8\x8d\xd3a\xcb\x12\xf1\xc1\x89m\xbb{f\xd9\x8b\xb9\x9c\xf0\xc1\xe6\xa2\\\xc1\xe9\xe6\xda\x9a\x8e\xf6\x95\x80\x14/R\xd6UK;>:-[\x04\xbe\xac\x12|f\xff\xd8bT\xfe\xfb\xa7\x82\xc8~\x8c\xd4)z\x13Y\x11\x97'\xd5\xc7_\xa9\x94\x88/\x8aD\x96\x93\x16\x17:\xa5\xc1\xef\xa0\x8d\x98\x17\xe5\x18\xf0\xfd\x87\xa1kw\xfb\xc9\xeb\xecE\x88\xc6\xb9\xf4\xfb\xd0\x0e=A\xfb\xcc}qC\xf4i\x1a\xed\xee~\xc0\x1fg\x00\x94\xea\x0b\xab\x03\x17\x8d\x00\xba\xc9N\x02\xe4\xf2\xe1\xf9\x10 \xb3n\xc8\r\x8c2\xa1\xa0\xdaM\x9b\xa7i^P\xf9\x18\xbb\xd8\xcc,,\xcb\x9d\xaa\x9d>H\xa1m\xb0\xb5\xcc\xba\x16\xd2<"
Verified: True
Concluding Thoughts#
In cryptography, it is crucial not to rely on security through obscurity, such as keeping algorithms secret instead of using well-vetted, publicly reviewed standards. Never roll your own cryptographic algorithms or protocols—even experienced developers can introduce fatal flaws without realizing it. Avoid using outdated or broken algorithms like MD5 or SHA-1, and do not hard-code encryption keys or secrets into your code or repositories. Improper key management, weak random number generation, and ignoring secure padding or initialization vectors can all lead to catastrophic vulnerabilities. Always follow established cryptographic best practices and standards, and stay informed about current security recommendations and threats.
Education and appropriate use of existing algorithms (and their implementations) are essential. Hackers rely more upon cryptographic failures than upon breaking encryption.
Diagram sources#
graph LR
A[Original Data / Message 📄] --> B[Hash Function 🔁] --> C[Fixed-Length Hash Value 🧩]
style A fill:#f0f4f8,stroke:#012169,stroke-width:2px
style B fill:#4973B8,stroke:#012169,stroke-width:2px,color:#ffffff
style C fill:#dce3ee,stroke:#012169,stroke-width:2px
flowchart LR
A[Plaintext Message 📄] --> B[Encryption Algorithm\n+ Secret Key 🔑]
B --> C[Ciphertext 🕵️♂️]
C --> D[Decryption Algorithm\n+ Secret Key 🔑]
D --> E[Original Message 📄]
style A fill:#f0f4f8,stroke:#012169,stroke-width:2px
style B fill:#4973B8,stroke:#012169,stroke-width:2px,color:#ffffff
style C fill:#dce3ee,stroke:#012169,stroke-width:2px
style D fill:#4973B8,stroke:#012169,stroke-width:2px,color:#ffffff
style E fill:#f0f4f8,stroke:#012169,stroke-width:2px
flowchart LR
A[Bob's Public Key 🔓] -->|Encrypt Message| B[Encrypted Message 📦]
B -->|Send over Network| C[Network 🌐]
C --> D[Bob Receives Message 📥]
D -->|Decrypt with Private Key| E[Bob's Private Key 🔐]
E --> F[Original Message 📄]
%% Styling with a Duke-inspired color palette
style A fill:#012169,stroke:#012169,color:#ffffff,stroke-width:2px
style B fill:#4973B8,stroke:#012169,stroke-width:2px,color:#ffffff
style C fill:#dce3ee,stroke:#012169,stroke-width:2px
style D fill:#4973B8,stroke:#012169,stroke-width:2px,color:#ffffff
style E fill:#012169,stroke:#012169,color:#ffffff,stroke-width:2px
style F fill:#f0f4f8,stroke:#012169,stroke-width:2px