Skip to content

Instantly share code, notes, and snippets.

View natmchugh's full-sized avatar

Nathaniel McHugh natmchugh

View GitHub Profile
@natmchugh
natmchugh / Makefile
Created May 6, 2015 07:37
Makefile for fast coll
fastcoll:
g++ -O3 *.cpp -lboost_filesystem -lboost_program_options -lboost_system -o fastcoll
@natmchugh
natmchugh / rsa120.py
Created March 11, 2015 15:56
Print out plain test of message for RSA129
import string, sys
def extended_gcd(aa, bb):
lastremainder, remainder = abs(aa), abs(bb)
x, lastx, y, lasty = 0, 1, 1, 0
while remainder:
lastremainder, (quotient, remainder) = remainder, divmod(lastremainder, remainder)
x, lastx = lastx - quotient*x, x
y, lasty = lasty - quotient*y, y
return lastremainder, lastx * (-1 if aa < 0 else 1), lasty * (-1 if bb < 0 else 1)
@natmchugh
natmchugh / soroban.py
Created November 23, 2016 11:08
Script what I wrote to learn to recognise numbers on a soroban
import re, random, operator
random.seed()
def get_random_int():
return random.randint(1,999)
def to_soroban(number):
digits = {
0: "**** || *",
1: "*** *|| *",
import random, operator
random.seed()
def get_random_int():
return random.randint(2, 12)
numberOfQs = 10
ops = {"+": operator.add,
"-": operator.sub,
"*": operator.mul,
@natmchugh
natmchugh / fast_reverse.c
Created October 4, 2016 16:35
get the internal state from a PHP lcg in 3 outputs
/*
*
*/
#include <stdio.h>
#include <math.h>
#define MODMULT(a, b, c, m, s) q = s/a;s=b*(s-a*q)-c*q;if(s<0)s+=m;
/* MODMULT computes s*b mod m, provided that m=a*b+c and 0<=c<m */
@natmchugh
natmchugh / cpc.sh
Last active July 19, 2016 11:08
My version of hash clashes shell script with some things fixed
#!/bin/bash
export BIRTHDAYSEARCH=../md5birthdaysearch
export HELPER=../md5diffpathhelper
export FORWARD=../md5diffpathforward
export BACKWARD=../md5diffpathbackward
export CONNECT=../md5diffpathconnect
export CPUS=8
export TTT=12
@natmchugh
natmchugh / lcg.php
Created February 23, 2016 13:51
Brute forcing the seeding of PHP's lcg
<?php
class Lcg
{
private $s1 = 0;
private $s2 = 0;
public function __construct($s1, $s2)
{
$this->s1 = $s1;
@natmchugh
natmchugh / MersenneTwister.php
Created February 18, 2016 14:14
Pure PHP implementation of mt19937 with standard or PHP behaviours
<?php
class MersenneTwister
{
const STANDARD = 1;
const PHP = 2;
// Create a length 624 array to store the state of the generator
private $MT;
<?php
define('π', M_PI);
var_dump(π);
<?php
require (__DIR__.'/../vendor/autoload.php');
use Guzzle\Http\Client;
use Fishtrap\Guzzle\Plugin\OAuth2Plugin;
use Guzzle\Log\MessageFormatter;