This file contains 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
class EventListener<T> { | |
private callbacks:{(user : T) : void}[] = []; | |
addEventListener(callback:{(user : T) : void}):void { | |
this.callbacks.push(callback); | |
} | |
removeEventListener(callback:{(user: T) : void}):void { | |
this.callbacks.splice(this.callbacks.lastIndexOf(callback)); | |
} |
This file contains 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 "aes.h" | |
// This function produces Nb(Nr+1) round keys. The round keys are used in each round to decrypt the states. | |
static void KeyExpansion(void) | |
{ | |
uint32_t i, j, k; | |
uint8_t tempa[4]; // Used for the column/row operations | |
// The first round key is the key itself. | |
for(i = 0; i < Nk; ++i) |
This file contains 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 "md5.h" | |
char* md5(const char* src) | |
{ | |
unsigned char* buffer = (unsigned char*) malloc(16 + 1); | |
MD5_CTX ctx; | |
MD5_Init(&ctx); | |
MD5_Update(&ctx, src, strlen(src)); | |
MD5_Final(buffer, &ctx); |
This file contains 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 "base64.h" | |
void build_decoding_table() | |
{ | |
int i; | |
decode_table = (char*) malloc(128); | |
for (i = 0; i < 64; i++) | |
decode_table[encode_table[i]] = i; | |
} |
This file contains 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 "hexutil.h" | |
short char2int(char c) | |
{ | |
if (c >= 'a' && c <= 'f') | |
return c - 'a' + 10; | |
if (c >= 'A' && c <= 'F') | |
return c - 'A' + 10; | |