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 os, math, binascii | |
from Crypto.Cipher import AES | |
def XOR_hex(h1, h2): | |
ans_hex = hex(int(h1, 16) ^ int(h2, 16))[2:] | |
if (ans_hex[-1] == "L"): | |
ans_hex = ans_hex[:-1] | |
return ans_hex.zfill(len(h1)) | |
def XOR_raw(r1, r2): |
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
def api(N, U): | |
M = matrix(ZZ, 2,2, [1, -floor(pi*2^N)*2^N, 0, 2^(2*N)]) | |
M = U*M | |
M = U.augment(M) | |
UM = M.LLL() | |
return UM.submatrix(0,0,2,2) | |
U = identity_matrix(2) | |
for i in range(1,100): | |
U = api(3*i, U) | |
approx = U[0][1]/U[0][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
var http = require("http"); | |
console.log("Started server"); | |
var myServer = http.createServer(function(request, response){ | |
console.log(request); | |
console.log(response); | |
response.setHeader('Content-Type', 'text/html'); | |
response.write("<p>Hello there</p>"); | |
response.end("<p>I think I'm done</p>"); | |
}); |
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
var http = require("http"); | |
var express = require('express'); | |
console.log("Started server"); | |
var aRouter = express(); | |
var myServer = http.createServer(aRouter); | |
aRouter.get('/', function(req, res){ | |
res.send("Testing Express"); | |
}); |
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
var http = require("http"); | |
var express = require('express'); | |
console.log("Started server"); | |
var aRouter = express(); | |
var myServer = http.createServer(aRouter); | |
aRouter.get('/users/:userid', function(req, res){ | |
res.send("You asked for data from User "+req.params.userid); | |
}); |
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
var http = require("http"); | |
var express = require('express'); | |
var bodyParser = require('body-parser'); | |
console.log("Started server"); | |
var aRouter = express(); | |
var myServer = http.createServer(aRouter); | |
aRouter.use(bodyParser.json()); | |
aRouter.use(bodyParser.urlencoded({ extended: true })); | |
aRouter.use(express.static(__dirname + "/client")); |
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
<?php | |
function xorIt($charOne, $charTwo) | |
{ | |
return $charOne ^ $charTwo; | |
} | |
function asciiValue($char) | |
{ | |
return ord($char); |
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
def adj(A): | |
labels = [[-1 for i in A[0]] for j in A] | |
next_label = 0 | |
linked = {} | |
for row in range(len(A)): | |
for col in range(len(A[0])): | |
nbrs = [] | |
not_nbrs=[] | |
if row >= 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
import random,copy | |
W1 = [[random.random()*.2, random.random()*.2, random.random()*.2] for i in range(3)] | |
W2 = [[random.random()*.2, random.random()*.2, random.random()*.2] for i in range(3)] | |
#an empty 3x3 matrix | |
def activation(a_float): | |
return round(a_float) | |
def apply_input(input_in, W): | |
input = copy.copy(input_in) | |
input.append(-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
def safe_prime(bits): | |
found_safe_prime = False | |
ohshit = 0 | |
while (not found_safe_prime and ohshit < 1000000): | |
ohshit += 1 | |
q = 2*randint(2**(bits-1), 2**(bits))-1 | |
if power_mod(2,2*q, 2*q + 1) != 1: | |
continue | |
if not q.is_prime(False): | |
continue |