Skip to content

Instantly share code, notes, and snippets.

View Shrusti-04's full-sized avatar

Shrusti siddanagoudar Shrusti-04

View GitHub Profile
# captcha_app.py
# Simple CAPTCHA demo using `captcha` and Flask
# NOTE: For lab/demo only. Do not use this exact secret_key or plaintext keys in production.
from flask import Flask, render_template_string, request, session
from captcha.image import ImageCaptcha
import random, string, io, base64
app = Flask(__name__)
app.secret_key = "change_this_in_lab" # replace with secure random key for real use
@Shrusti-04
Shrusti-04 / gist:acc5b60d52b7f4f0427ed055a20a922a
Created November 1, 2025 08:20
password_cracker.py (dictionary attack)
# password_cracker.py
import hashlib
def try_crack(hashfile="test_hashes.txt", wordlist="wordlist.txt"):
targets = []
with open(hashfile) as f:
for line in f:
salt_hex, h = line.strip().split(":")
targets.append((bytes.fromhex(salt_hex), h))
# generate_hashes.py
import hashlib
import os
def hash_password(password, salt=None):
if salt is None:
salt = os.urandom(8) # 8 bytes salt for demo
h = hashlib.sha256(salt + password.encode()).hexdigest()
return salt.hex(), h
# Experiment 2: Demo and Practice on Crypto Library
from cryptography.fernet import Fernet
# Step 1: Generate a key
key = Fernet.generate_key()
print("Encryption Key:", key)
# Step 2: Initialize Fernet object
cipher = Fernet(key)
@Shrusti-04
Shrusti-04 / gist:41cb0bc467d68410b1e8238964c35f06
Last active November 1, 2025 07:58
substitution_cipher.py.
# substitution_cipher.py
import string
# Caesar Cipher
def caesar_encrypt(plaintext, shift):
plaintext = plaintext.upper()
alphabet = string.ascii_uppercase
ciphertext = ""
for ch in plaintext:
if ch in alphabet: