Skip to content

Instantly share code, notes, and snippets.

View pedropedruzzi's full-sized avatar

Pedro Pedruzzi pedropedruzzi

View GitHub Profile
#include <iostream>
using Age = unsigned int;
using Name = std::string;
using Country = std::string;
template <class PersonSubtype>
class Person
{
class Digraph:
def __init__(self):
self.d = {}
def has(self, x, y):
return x in self.d and y in self.d[x]
def _safe_get(self, x):
return self.d.setdefault(x, set())
@pedropedruzzi
pedropedruzzi / crack-djbx31a.py
Last active August 29, 2015 14:02
Meet-in-the-middle crack for DJBX31A hash function
# http://events.ccc.de/congress/2011/Fahrplan/attachments/2007_28C3_Effective_DoS_on_web_application_platforms.pdf
import random
# djbx31a backward
def rev(h, s):
for c in reversed(s):
h = ((h - ord(c)) * 3186588639) & 0xffffffff;
return h