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
/** | |
* Taken from Nikita Popov's answer on stack overflow: http://stackoverflow.com/questions/16489509/decrypting-aes-ctr-little-endian-with-php | |
*/ | |
static public function ctr_crypt($str, $cipher = MCRYPT_RIJNDAEL_256, $key, $iv) { | |
$numOfBlocks = ceil(strlen($str) / 16); | |
$ctrStr = ''; | |
for ($i = 0; $i < $numOfBlocks; ++$i) { | |
$ctrStr .= $iv; |
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
// 6. Encrypt inner packet | |
$blob = $inner_packet->encode(); | |
$cipher = new \Crypt_AES(CRYPT_AES_MODE_CTR); | |
$cipher->setIv($iv); | |
$cipher->setKey($hash); | |
$body = $cipher->encrypt($blob); |
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
// 7. Create sig | |
// This is why we can't have nice things | |
if (! defined('OPENSSL_ALGO_SHA256')) define('OPENSSL_ALGO_SHA256', 7); | |
// // sign & encrypt the sig | |
// var md = forge.md.sha256.create(); | |
// md.update(body.bytes()); | |
// var sig = id.private.sign(md); | |
openssl_sign($body, $sig, $my_priv_key, OPENSSL_ALGO_SHA256); |
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
All application packets are marked with the "_xfer" type. | |
Returning a listing of all files from a particular node: | |
Request: | |
{ | |
type : '_xfer', | |
_ : { | |
request : 'list' |
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
filter: | |
paths: [lib/*] | |
excluded_paths: [vendor/*, tests/*] | |
before_commands: | |
- 'composer install --dev --prefer-source' | |
tools: | |
external_code_coverage: true | |
php_mess_detector: true | |
php_code_sniffer: true | |
sensiolabs_security_checker: true |
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
/** gcc -g -O0 -fno-inline -o test test.c `pkg-config --libs --cflags icu-uc icu-io` */ | |
// We will be using UTF8 | |
#define U_CHARSET_IS_UTF8 1 | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include "unicode/uchar.h" | |
#include "unicode/ucnv.h" |
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
class string { | |
public method pad(numerical width, numerical direction = PAD_RIGHT); // PAD_LEFT, PAD_RIGHT, PAD_BOTH | |
public method utf8(); // shortcut to convert("utf-8"); | |
public method utf16(); // shortcut to convert("utf-16"); | |
public method bytes(); // Return some kind of bytestream? | |
public method convert(string charset); // Convert to different charset | |
public method byte_length(); // Returns number of BYTES in this string (which can be more than actual characters) | |
public method char_length(); // shortcut to length(); |
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
#define MAXLED 3 | |
int ledPins[MAXLED][3] = { | |
{2,3,4}, | |
{5,6,7}, | |
{8,9,10}, | |
}; | |
typedef struct _rgb { |
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
#!/bin/sh | |
php composer.phar create-project symfony/framework-standard-edition $1 | |
cd $1 | |
ln -s web public | |
sed -i public/app_dev.php -e '/header/s|^|//|' -e '/exit/s|^|//|' | |
sudo setfacl -R -m u:www-data:rwX -m u:jthijssen:rwX app/cache app/logs |
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 io; | |
class foo { | |
public method bar() { | |
try { | |
io.print("try\n"); | |
return "1"; | |
} catch (exception e) { | |
io.print("exception\n"); |