Skip to content

Instantly share code, notes, and snippets.

@cbscribe
cbscribe / make_rsa_keys.py
Created February 2, 2022 15:57
Create public/private RSA key pair
from Crypto.PublicKey import RSA
key_pair = RSA.generate(2048)
print("p: ", key_pair.p)
print("q: ", key_pair.q)
print("m: ", key_pair.n)
print("e: ", key_pair.e)
print("d: ", key_pair.d)
@cbscribe
cbscribe / volume.c
Created October 21, 2021 04:37
Distribution code for Lab 4: Volume
// Modifies the volume of an audio file
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
// Number of bytes in .wav header
const int HEADER_SIZE = 44;
int main(int argc, char *argv[])
@cbscribe
cbscribe / readability.py
Last active October 19, 2021 05:25
Readability starting code
def count_letters(text):
# TODO: Count the number of letters
num_letters = 0
print(num_letters, "letter(s)")
return num_letters
def count_words(text):
# TODO: Count the number of words
num_words = 0
@cbscribe
cbscribe / grade7.html
Created September 23, 2021 17:49
Mr. Bradfield's homepage example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mr. Bradfield's Classes</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!--navigation bar-->
<ul class="nav">
<li class="nav"><a href="index.html">Home</a></li>
@cbscribe
cbscribe / example.html
Last active September 23, 2021 15:28
HTML Example
<!DOCTYPE html>
<html lang="en">
<head>
<title>hello title</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<h1>Section 1</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Natoque penatibus et magnis dis parturient montes nascetur. Facilisi cras fermentum odio eu. At risus viverra adipiscing at in. Ac orci phasellus egestas tellus rutrum tellus pellentesque eu tincidunt. Blandit massa enim nec dui nunc mattis enim ut. Augue ut lectus arcu bibendum at varius vel. At augue eget arcu dictum varius duis. Duis ultricies lacus sed turpis. At augue eget arcu dictum. Egestas maecenas pharetra convallis posuere morbi leo urna molestie. Pretium vulputate sapien nec sagittis aliquam. Mattis nunc sed blandit libero volutpat sed cras ornare. Sit amet mattis vulputate enim. Eget nulla facilisi etiam dignissim diam quis enim lobortis scelerisque. Urna id volutpat lacus laoreet non cura
@cbscribe
cbscribe / pygame_template.py
Last active August 11, 2021 16:35
Pygame template
import pygame
import random
WIDTH = 800
HEIGHT = 600
FPS = 60
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
clock = pygame.time.Clock()
@cbscribe
cbscribe / jumper.py
Last active August 7, 2021 00:04
pygame jumper
# https://gist.github.com/cbscribe
import pygame
import random
WIDTH = 800
HEIGHT = 640
FPS = 60
RUN_SPEED = 11
GRAVITY = 2
JUMP_SPEED = -31
@cbscribe
cbscribe / snake.py
Last active July 23, 2021 23:05
Pygame programs
# https://gist.github.com/cbscribe
# To install pygame, open command prompt:
# pip install pygame
import pygame
import random
WIDTH = 800
HEIGHT = 600
@cbscribe
cbscribe / player.gd
Last active July 1, 2021 17:08
Player code for Godot platformer
extends KinematicBody2D
enum {IDLE, RUN, JUMP, HURT, DEAD}
var state
var anim
var new_anim
var run_speed = 150
var jump_speed = -320
var gravity = 750
var velocity = Vector2.ZERO
@cbscribe
cbscribe / rsa_manual.py
Last active May 27, 2021 03:14
Manually decrypt text RSA-style, given "N" and "D".
ciphertext = input("Ciphertext: ")
m = int(input("m: "))
d = int(input("D: "))
num_digits = len(str(m))
cleartext = ""
print("Decrypting (may take a while)...")
for i in range(0, len(ciphertext), num_digits):
num = int(ciphertext[i:i+num_digits])
cleartext += chr((num ** d) % m)
print()