Skip to content

Instantly share code, notes, and snippets.

View AndyNovo's full-sized avatar

Andy Novocin AndyNovo

View GitHub Profile
print "Andy rocks the casbah"
factors = (p-1).factor()
remainders = []
bases = []
for factor in factors:
p_i = factor[0]**factor[1]
LHS = pow(e, int((p-1)/p_i), p)
RHBase = pow(g, int((p-1)/p_i), p)
if RHBase == 1:
print "multiple"
for r_i in range(p_i):
p = 22382653690331959336999665583284427801
print p.is_prime()
for factor in (p-1).factor():
print factor
p = 22382653690331959336999665583284427801
print p.is_prime()
(p-1).factor()
from Crypto.Util.number import *
p = getStrongPrime(512)
a = getRandomRange(2, p-2)
print GCD(a, p-1)
#loop until you get a GCD of 1 with p-1
base = 2
A = pow(base, a, p)
print p, base, A
m="Hi there"
print m
hexstr = m.encode('hex')
print hexstr
integer_m = int(hexstr, 16)
import hashlib, cProfile
f=file('dictionary.txt','r')
words = [word.strip() for word in f]
f.close()
secretHash=hashlib.sha512("banana").hexdigest()
def checkDictionary(secret):
return [word for word in words if hashlib.sha512(word).hexdigest() == secret]
#include <cstring>
#include <stdexcept>
void go(char *data) {
char name[64];
strcpy(name, data);
}
int main(int argc, char **argv) {
go(argv[1]);
#include <stdio.h>
#include <sqlite3.h>
static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i<argc; i++){
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("\n");
return 0;
#include <stdio.h>
#include <gcrypt.h>
int main () {
size_t index;
size_t txtLength = 4;
char * hashBuffer = malloc(33);
char * textBuffer = malloc(txtLength+1);
memset(hashBuffer, 0, 33);