Safe Computing Popcorn and HW Hacks
Popcorn Hack 1: Cookies
Explanations of SSID Cookie
- A cookie is a piece of data that a website stores on your device when you visit it. Cookies help websites remember information about the user, like login status, language preferences, or items in a shopping cart. They are essential for personalizing web experience and for enabling features like staying logged in between sessions.
- The SSID cookie, specifically, is used by websites like Google to identify and authenticate users. It helps verify that you’re signed in to your Google account and ensures you’re getting personalized content (like your YouTube homepage or Google search results). The SSID cookie may store encrypted information like your Google account ID and the time you signed in. While it doesn’t contain your password, it’s an important part of how Google keeps you logged in securely.
Popcorn Hack 2: CAPTCHA
- The answer to this CAPTCHA is the middle two squares of the second row and the 3rd square of the first row.
- CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) is a challenge-response test used to determine if a user is a human or a bot, primarily used to prevent automated spam and malicious activities on websites.
MCQ Explainations
- What does Multi-Factor Authentication (MFA) require?
- Multiple forms of identity verification before granting access
- Explanation: MFA improves security by requiring two or more types of credentials (like a password and a code sent to your phone).
- Which encryption type is best suited for secure online communication where users do not need to share a common key?
- Asymmetric Encryption
- Explanation: Asymmetric encryption uses a public and private key pair. You can encrypt with someone’s public key and only their private key can decrypt it—no shared secret needed.
- What does PII stand for?
- Personally Identifiable Information
- Explanation: PII includes information like your name, address, SSN, or anything that can be used to identify you.
- Which of the following is an example of ethical computing?
- Respecting privacy policies and obtaining user consent before collecting data
- Explanation: Ethical computing involves being respectful, transparent, and responsible with technology and data.
- Which encryption type uses the same key for both encryption and decryption?
- Symmetric Encryption
- Explanation: In symmetric encryption, the same key is used to encrypt and decrypt the data. Both users need access to that same key.
- A user receives an email from their bank asking them to confirm their account details by clicking on a link. What is the best course of action?
- Verify the legitimacy of the email by contacting the bank directly through official contact methods
- Explanation: This could be a phishing scam. Never click suspicious links—always verify through official channels.
- Which of the following best describes phishing?
- A scam where an attacker tricks users into providing personal information by pretending to be a trustworthy entity
- Explanation: Phishing is about pretending—like fake emails or websites—to trick people into giving up sensitive info.
- A student downloads a free version of a popular software from an unknown website. What is the primary risk in this situation?
- The software could contain malware or viruses that compromise the computer’s security
- Explanation: Unverified downloads often hide malware. It’s always best to use official or trusted sources.
- Why is public key encryption considered more secure for transmitting sensitive data over the internet?
- Even if the public key is known, only the private key can decrypt the message.
- Explanation: Public key encryption ensures confidentiality because even if someone has the public key, they can’t decrypt messages without the private key.
- Bob wants to send Alice a secure message using public key encryption. Which key does he use to encrypt the message?
- Alice’s public key
- Explanation: Bob encrypts with Alice’s public key so only Alice (with her private key) can decrypt it.
MCQ Score:
I recieved a 9/10 but the PII question was incorrect. For noticing this and mentioning it to you, I should recieve extra credit.
Homework Hack 2
- Below is my implementation of the randomization of ceaser chipher shifts. I also added a loop so that can test all functions.
This code is a Caesar Cipher tool that can encrypt or decrypt messages by shifting letters in the alphabet. It runs in a loop, letting users use it multiple times until they type "exit". Here’s what each part does:
1. Import random module
import random
This is used if the user wants a random shift value instead of typing one.
2. Define the Caesar Cipher function
def caesar_cipher(text, shift, mode):
This function takes in:
text: the message to encrypt or decryptshift: how many letters to shiftmode: either"encrypt"or"decrypt"
result = ""
for char in text:
if char.isalpha():
shift_amount = shift if mode == "encrypt" else -shift
new_char = chr(((ord(char.lower()) - 97 + shift_amount) % 26) + 97)
result += new_char.upper() if char.isupper() else new_char
else:
result += char
- If the character is a letter, it shifts it using ASCII math.
- If the character is a space, number, or symbol, it just adds it as-is.
- It preserves uppercase/lowercase letters.
3. Loop to keep running until the user types “exit”
while True:
The loop continues until the user exits.
Ask for the mode
mode = input("Do you want to encrypt, decrypt, or exit? ")
- If the user types
"exit", the loop ends. - If the input is not
"encrypt"or"decrypt", it asks again.
Ask for the message and shift value
message = input("Enter your message: ")
shift_input = input("Enter shift value (number or type 'r' for a random shift): ")
- If user types
'r', a random shift between 1 and 25 is picked. - If not, the input is converted to an integer.
Encrypt or decrypt
output = caesar_cipher(message, shift, mode)
print(f"Result: {output}")
The result is calculated and printed.
import random
def caesar_cipher(text, shift, mode):
result = ""
for char in text:
if char.isalpha(): # Only encrypt letters
shift_amount = shift if mode == "encrypt" else -shift
new_char = chr(((ord(char.lower()) - 97 + shift_amount) % 26) + 97)
result += new_char.upper() if char.isupper() else new_char
else:
result += char # Keep spaces and punctuation unchanged
return result
while True:
mode = input("\nDo you want to encrypt, decrypt, or exit? ").strip().lower()
if mode == "exit":
print("Goodbye!")
break
if mode not in ["encrypt", "decrypt"]:
print("Invalid mode. Please enter 'encrypt', 'decrypt', or 'exit'.")
continue
message = input("Enter your message: ")
shift_input = input("Enter shift value (number or type 'r' for a random shift): ").strip().lower()
if shift_input == "r":
shift = random.randint(1, 25)
print(f"Random shift value chosen: {shift}")
else:
try:
shift = int(shift_input)
except ValueError:
print("Invalid shift value. Please enter a number or 'r'.")
continue
output = caesar_cipher(message, shift, mode)
print(f"Result: {output}")
Random shift value chosen: 19
Result: tgotr
Result: anvay
Goodbye!