Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <string.h>
int main()
{
// sha256 hash
char *hash = "B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9";
char *dividingChar = ":"; // The char to divide string
int length=strlen(hash);
int size = length+(length/3)+1; //size of final result
@kylelk
kylelk / struct_test.c
Created December 31, 2013 07:36
struct_test.c
#include <stdio.h>
#include <string.h>
struct Foo
{
char *data;
char *data2;
int length;
};
int main()
@kylelk
kylelk / code_gen.c
Created December 31, 2013 06:48
code_gen.c
#include <stdio.h>
#define WIDTH 10
int main()
{
int n;
int count=0;
printf("{");
for (n = 0; n <99; n++)
{
Process: eclipse [9939]
Path: /Applications/adt-bundle-mac-x86_64-20131030/*/Eclipse.app/Contents/MacOS/eclipse
Identifier: org.eclipse.eclipse
Version: 3.8 (3.8)
Code Type: X86-64 (Native)
Parent Process: launchd [243]
Responsible: eclipse [9939]
User ID: 502
Date/Time: 2013-12-28 18:05:07.685 -0800
@kylelk
kylelk / blockchain_data.py
Created December 28, 2013 07:18
Python script to get the bitcoin block chain.
import urllib, json, time
url = "http://blockchain.info/rawblock/"
hash = "0000000000000000d621e4c3182eb6015369fc156d5ce28e0b929da54d1c745a"
for _ in range(20):
r = urllib.urlopen(url+hash)
data = json.loads(r.read())
index = str(data["block_index"])
hash = str(data["prev_block"])
open("chain/"+index+".txt", "w").write(str(data))
@kylelk
kylelk / gcd_asm.c
Created December 27, 2013 23:31
Compute Greatest Common Divisor using Euclid's Algorithm
#include <stdio.h>
int gcd( int a, int b ) {
int result ;
/* Compute Greatest Common Divisor using Euclid's Algorithm */
__asm__ __volatile__ ( "movl %1, %%eax;"
"movl %2, %%ebx;"
"CONTD: cmpl $0, %%ebx;"
"je DONE;"
"xorl %%edx, %%edx;"
@kylelk
kylelk / sha256.py
Created December 27, 2013 21:15
Python implantation of sha256
def sha256(data):
bytes = ""
h0 = 0x6a09e667
h1 = 0xbb67ae85
h2 = 0x3c6ef372
h3 = 0xa54ff53a
h4 = 0x510e527f
h5 = 0x9b05688c
h6 = 0x1f83d9ab
This file has been truncated, but you can view the full file.
efb71441e7f7ef2bd55e613fbe4168b402fd1152fd754579bbee2417feea0759
2e1ae00ea48edb1ee1a6bc859456089559d531a7a946800b4dcd176ff0cb54f8
66098154ab61b7c0e10e2f3912f024d85cb9d371ad122758bab9eb8da28fcd5f
19d9b8ada70f742c61482312f540f4cc769b28f1ffbfc45d1563ad4a0fe0c153
a683029ce75a906e593f29d1abb4294b667d2c9089ab43b873410abe4ab34fda
581cf891404b2b7ad7939df9dc27c4d2485322477049efd49839830da31241f0
2968434135596bd43f1620b95e7cdf936c76d9b3a153aaa8a4e9a3befb58978c
1d79f8bfdf6bc9f4d0eb403b6839181879e52e80f1fd0577de477a863e8d1cbc
8bbe5c11c00bf094d053111a08a993363d24187a2a644adf598d341a229cdbfb
a202e92b53032deae0b5c51a6948f0c5d7fa312c71543579c62b5f1cb539523f
@kylelk
kylelk / hexdump.py
Created December 25, 2013 07:35
Python create a HTML hex dump.
data=open(__file__).read()
count = 0
for byte in data:
if count==8:
print ""
count=0
print "&#x"+'{0:02X}'.format(ord(byte))+";",
count+=1
1286b1ef093122af2f8dcbebfe9cba0e4e530e77