This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "Andy rocks the casbah" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p = 22382653690331959336999665583284427801 | |
print p.is_prime() | |
for factor in (p-1).factor(): | |
print factor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p = 22382653690331959336999665583284427801 | |
print p.is_prime() | |
(p-1).factor() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m="Hi there" | |
print m | |
hexstr = m.encode('hex') | |
print hexstr | |
integer_m = int(hexstr, 16) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstring> | |
#include <stdexcept> | |
void go(char *data) { | |
char name[64]; | |
strcpy(name, data); | |
} | |
int main(int argc, char **argv) { | |
go(argv[1]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |