Skip to content

Instantly share code, notes, and snippets.

View siddMahen's full-sized avatar

Siddharth Mahendraker siddMahen

  • Toronto, Canada
View GitHub Profile
@siddMahen
siddMahen / crypto-week-one.md
Last active August 9, 2018 14:09
Coursera cryptography lecture notes, from week one.

Crypto Notes Week 1

The first half of the course will be about sym. enc. and the second half will be about public key enc.

Introduction and Prereqs

What is cryptography?

The core of cryptography is about:

  • establishing a secret key between two parties

Crypto Notes Week 2

Introduction to Block Ciphers

A block cipher is a cipher (E,D) which (given a key) takes n bits of PT as input and outputs n bits of CT.

Examples include:

  • 3DES: n = 64 bits, k = 168 bits
  • AES: n = 128 bits, k = 128, 192, 256 bits
# factorization algorithm based on gcd
#
# could be vastly improved, this is barely better than
# naive
function fac(n::BigInt)
factors = Dict{BigInt,BigInt}()
while !isprime(n::BigInt)
@siddMahen
siddMahen / mandelbrot.pde
Last active December 29, 2015 22:18
Mandelbrot fractals in Processing.
int maxiter = 500;
//float zoom = 0.005;
//float fx = -0.745;
//float fy = 0.1;
float zoom = 4;
float fx = 0;
float fy = 0;
@siddMahen
siddMahen / prim.py
Created January 4, 2014 22:03
Prim's algorithm, in Python.
from sys import argv
import re
# open the file and get read to read data
file = open(argv[1], "r");
p = re.compile("\d+");
# initialize the graph
vertices, edges = map(int, p.findall(file.readline()))
graph = [[0]*vertices for _ in range(vertices)]
@siddMahen
siddMahen / roth.py
Last active August 29, 2015 13:56
Calculate a maximal length 3 progression free subset of [N].
from sys import argv
import math
N = int(argv[1])
S = set();
k = N
for j in range(1,N+1):
S.add(j)
var algorithms = require("algorithms"),
fs = require("fs");
var dynamicLowMem = function(capacity, values, weights){
var max = function(x, y){
return x ^ ((x ^ y) & -(x < y));
}
var items = values.length,
value = 0,
using Winston
x = Int[]
y = Int[]
for i = 2:20, j = 2:20
if (rem(i,j) != 0) && (rem(BigInt(i)^i,BigInt(j)^j) == 0)
push!(x,i)
push!(y,j)
end
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
navigator.webkitGetUserMedia({audio:true}, function(s){
window.AudioContext = window.AudioContext || window.webkitAudioContext;
@siddMahen
siddMahen / gaussian.html
Last active August 29, 2015 14:01
Naive Gaussian distributions in Javascript.
<!DOCTYPE html>
<html>
<head>
<title>Gaussian Distributions</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
.chart div {
background-color: steelblue;
font: 10px sans-serif;
border: 2px solid white;