charles.robbins
charles.robbins 5d ago โ€ข 10 views

Cryptography Code Examples: Encrypting and Decrypting Data in Python

Hey there! ๐Ÿ‘‹ Ready to dive into the fascinating world of cryptography with Python? ๐Ÿ This guide will give you a quick rundown of the key concepts, followed by a fun quiz to test your knowledge. Let's get coding!
๐Ÿ’ป Computer Science & Technology

1 Answers

โœ… Best Answer
User Avatar
emily833 Dec 30, 2025

๐Ÿ“š Quick Study Guide

  • ๐Ÿ”‘ Encryption: The process of converting plaintext (readable data) into ciphertext (unreadable data).
  • ๐Ÿ—๏ธ Decryption: The reverse process of converting ciphertext back into plaintext.
  • ๐Ÿงฎ Caesar Cipher: A simple substitution cipher where each letter is shifted by a fixed number of positions in the alphabet.
  • ๐Ÿ”’ Symmetric-key Cryptography: Uses the same key for both encryption and decryption (e.g., Caesar Cipher, AES).
  • ๐Ÿ›ก๏ธ Asymmetric-key Cryptography: Uses separate keys for encryption and decryption (public key and private key) (e.g., RSA).
  • ๐Ÿ Python Libraries: `cryptography` library provides robust encryption tools.
  • ๐Ÿ”ข Modular Arithmetic: Essential for many cryptographic algorithms (e.g., $a \equiv b \pmod{m}$).

Practice Quiz

  1. Which of the following is the process of converting readable data into an unreadable format?
    1. Encryption
    2. Decryption
    3. Hashing
    4. Compression
  2. What type of cryptography uses the same key for both encryption and decryption?
    1. Asymmetric-key
    2. Symmetric-key
    3. Hashing
    4. Digital Signature
  3. Which of the following is a simple substitution cipher?
    1. AES
    2. RSA
    3. Caesar Cipher
    4. SHA-256
  4. Which Python library is commonly used for implementing cryptographic functions?
    1. `math`
    2. `os`
    3. `cryptography`
    4. `random`
  5. In asymmetric-key cryptography, what are the two keys called?
    1. Public and Secret
    2. Encryption and Decryption
    3. Private and Shared
    4. Public and Private
  6. What is the purpose of decryption?
    1. To compress data
    2. To convert ciphertext to plaintext
    3. To convert plaintext to ciphertext
    4. To hash data
  7. Which of the following algorithms is an example of asymmetric-key cryptography?
    1. AES
    2. DES
    3. RSA
    4. Caesar Cipher
Click to see Answers
  1. A
  2. B
  3. C
  4. C
  5. D
  6. B
  7. C

Join the discussion

Please log in to post your answer.

Log In

Earn 2 Points for answering. If your answer is selected as the best, you'll get +20 Points! ๐Ÿš€