Skip to content

Instantly share code, notes, and snippets.

View montyanderson's full-sized avatar

Monty Anderson montyanderson

View GitHub Profile
int a[4][4] = {
{ 1, 2, 3, 4 },
{ 5, 6, 7, 8 },
{ 9, 1, 1, 2 },
{ 3, 4, 5, 6 }
}
int b[4][4] = {
{ 1, 2, 3, 4 },
{ 5, 6, 7, 8 },
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#define PORT 1153
int main() {
#define H0 0x6a09e667
#define H1 0xbb67ae85
#define H2 0x3c6ef372
#define H3 0xa54ff53a
#define H4 0x510e527f
#define H5 0x9b05688c
#define H6 0x1f83d9ab
#define H7 0x5be0cd19
const uint32_t k[64] = {
/* jslint esversion:6*/
var fs = require("fs");
var express = require('express');
var session = require('express-session');
var bodyParser = require('body-parser');
var app = require("express")();
var http = require("http").Server(app);
var io = require("socket.io")(http);
var PORT = 3000;
# extremely simple, slow BigNum library, using everything as repeated addition
#include <stdio.h>
#include <stdint.h>
#include <string.h>
typedef uint8_t BigNum_word;
#define BIGNUM_WORDS 192
#define BIGNUM_WORD_MAX 255
// mulmod(a, b, c)
// calculates a^b & c, where the resulting power may be larger than 2^64.
// works for pretty much infinitely high exponents, as long as (a * c) < 2^64
uint64_t mulmod(uint64_t a, uint64_t b, uint64_t c) {
uint64_t res = 1;
for(uint64_t i = 0; i < b; i++) {
res *= a;
res %= c;
// my second successful implementation of sha256 in C
// note: it only works for one block of data (<48 bytes)
// O(1) memory usage and endianness checking
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <byteswap.h>
#include <endian.h>
// my second successful implementation of sha256 in C
// note: it only works for one block of data (<48 bytes)
// O(n) memory usage
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <byteswap.h>
#define H0 0x6a09e667
// my first successful implementation of sha256 in C
// note: it only works for one block of data (<48 bytes)
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <byteswap.h>
#define H0 0x6a09e667
#define H1 0xbb67ae85
void slowcopy(char *a, char *b, size_t len) {
for(size_t i = 0; i < len; i++) {
a[i] = b[i];
}
}
void fastcopy(char *a, char *b, size_t len) {
size_t i;
for(i = 0; i < len; i += sizeof(long int)) {