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
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
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
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
import binascii, hashlib | |
hexascii = hashlib.sha256("andy").hexdigest() | |
realhex = hashlib.sha256("andy").digest() | |
binary_for_hexascii = "" | |
binary_for_realhex = "" | |
for character in hexascii: | |
binary_for_hexascii += bin(ord(character))[2:].zfill(8) |
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 random | |
def shiftBy(c, n): | |
return chr(((ord(c) - ord('a') + n) % 26) + ord('a')) | |
def encode(raw, keyLength): | |
key = [random.randint(1,25) for i in range(keyLength)] | |
secret = "".join([shiftBy(raw[i], key[i % keyLength]) for i in range(len(raw))]) | |
withSpaces = '' | |
for i in range(len(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
#data derived from http://www.data-compression.com/english.html | |
freqs = {'a': 0.080642499002080981, 'c': 0.026892340312538593, 'b': 0.015373768624831691, 'e': 0.12886234260657689, 'd': 0.043286671390026357, 'g': 0.019625534749730816, 'f': 0.024484713711692099, 'i': 0.06905550211598431, 'h': 0.060987267963718068, 'k': 0.0062521823678781188, 'j': 0.0011176940633901926, 'm': 0.025009719347800208, 'l': 0.041016761327711163, 'o': 0.073783151266212627, 'n': 0.069849754102356679, 'q': 0.0010648594165322703, 'p': 0.017031440203182008, 's': 0.063817324270355996, 'r': 0.06156572691936394, 'u': 0.027856851020401599, 't': 0.090246649949305979, 'w': 0.021192261444145363, 'v': 0.010257964235274787, 'y': 0.01806326249861108, 'x': 0.0016941732664605912, 'z': 0.0009695838238376564} | |
sum_f_squared = 0.0 | |
sum_f = 0.0 | |
for key in freqs: | |
sum_f += freqs[key] | |
sum_f_squared += freqs[key]**2 | |
print sum_f |
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 urllib2, ssl | |
response = urllib2.urlopen("https://vip.udel.edu/crypto/mobydick.txt", context=ssl._create_unverified_context()) | |
mobytext = response.read() | |
onlyletters = filter(lambda x: x.isalpha(), mobytext) | |
loweronly = onlyletters.lower() | |
frequency = {} | |
for ascii in range(ord('a'), ord('a')+26): |
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 urllib2, random | |
response = urllib2.urlopen("http://vip.udel.edu/crypto/mobydick.txt") | |
mobytext = response.read() | |
onlyletters = filter(lambda x: x.isalpha(), mobytext) | |
loweronly = onlyletters.lower() | |
def shiftBy(c, n): | |
return chr(((ord(c) - ord('a') + n) % 26) + ord('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
#include <iostream> | |
using namespace std; | |
int main(){ | |
cout << "Content-type: text/html" << endl; | |
cout << endl; | |
cout << "<!doctype html><html><body>"<<endl; | |
cout << "Hi there. I rule!" << endl; | |
cout << "</body></html>" << endl; |