Skip to content

Instantly share code, notes, and snippets.

View MidnightLightning's full-sized avatar

Brooks Boyd MidnightLightning

View GitHub Profile
@MidnightLightning
MidnightLightning / README.md
Created July 27, 2012 01:50
Steganography tools

Steganography: the art of hiding in plain sight. Messages specifically. These are a series of tools that aid in embedding messages in digital files.

While steganography provides obscurity, it does not strictly provide security. Before hiding your message using any of these scripts, it's suggested you encode your message (try PGP/GnuPG encryption or put it in a TrueCrypt container if you're at a loss).

pngload.py

The PNG file format divides the image data into 'chunks', and allows for additional, private chunks to be added by image editors. This script takes the message you wish to embed and saves it as binary data in such an ancillary chunk.

The files being embedded are compressed with bzip2 compression if they're not already a bzip2 archive. This is different from the `

@MidnightLightning
MidnightLightning / btc.html
Created March 3, 2013 23:08
Use AJAX to drop in a price in BTC on page load. If javascript fails, the page just displays the USD amount. It needs a PHP file to proxy the blockchain.info ticker, since it does not have Cross-Origin headers.
<html>
<head><title>BTC prices</title></head>
<body>
<p>Buy this widget for $10<span id="btc"></span>.</p>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$.ajax({
url: 'btc.php',
@MidnightLightning
MidnightLightning / README.md
Last active December 30, 2015 23:28
Experimenting with Typed Arrays in Node.js

Node Buffer objects say:

A Buffer object can also be used with typed arrays. The buffer object is cloned to an ArrayBuffer that is used as the backing store for the typed array. The memory of the buffer and the ArrayBuffer is not shared.

NOTE: Node.js v0.8 simply retained a reference to the buffer in array.buffer instead of cloning it.

While more efficient, it introduces subtle incompatibilities with the typed arrays specification. ArrayBuffer#slice() makes a copy of the slice while Buffer#slice() creates a view."

@MidnightLightning
MidnightLightning / package.json
Last active August 29, 2015 14:01
Testing Big Integer performance
{
"name": "mathbuffer-test",
"version": "0.1.0",
"description": "Testing Big Integer implementation performance",
"main": "test.js",
"dependencies": {
"math-buffer": "~0.1.1",
"bigi": "~1.1.0"
},
"author": "Brooks Boyd <boydb@midnightdesign.ws>"
Verifying that +midnight is my Bitcoin username. You can send me #bitcoin here: https://onename.io/midnight
@MidnightLightning
MidnightLightning / blowfish.inc.php
Last active February 10, 2016 19:32
Blowfish encryption
<?php
/**
* Utilize the Blowfish encryption algorithm without using mcrypt extension
* @package Encryption
* @author Brooks Boyd <boydb@midnightdesign.ws>
* @version 1.0
*/
/**
* Object for holding encryption key schedule and processing
* @package Encryption
@MidnightLightning
MidnightLightning / stitch.php
Created February 10, 2016 19:33
Crosstitch converter
<?php
// Take an image and convert it into a crosstitch grid
function textImage($msg = "No message") {
$char_size = 3; # Which standard font size?
$char_height = 35; # How tall is a line?
$char_width = 7; # How wide is each character?
// Determine width based on string length
$width = strlen($msg)*$char_width+30;
@MidnightLightning
MidnightLightning / dimetric.php
Created February 10, 2016 19:35
Dimetric SVG creation
<?php
// Create Dimetric SVG image
// Diametric is a parallel projection similar to isometric (30 degrees x 30 degrees grid) which is unequal (15 degrees x 60 degrees).
// To make a unit square, starting at (0,0), on the SVG canvas (Y axis flipped) as the closest point and going clockwise,
// the other points are (-cos(15), -sin(15)), (-cos(15)+cos(60), -sin(15)-sin(60)), (cos(60), -sin(60))
// or, (-0.965925826289068, -0.258819045102521), (-0.465925826289068, -1.12484444888696), (0.50, -0.866025403784439)
$unit_square = new Polygon(
new Point(0,0),
@MidnightLightning
MidnightLightning / http.inc.php
Created February 10, 2016 19:37
HTTP Transfer class
<?php
/**
* HTTP transfer class
* @author Brooks Boyd
* @version 1.0
* @package simpleHTTP
*/
/**
* Interface used for fetching http data
@MidnightLightning
MidnightLightning / img.inc.php
Last active April 28, 2017 04:46
Image generating utility functions
<?php
function textImage($msg = "No message") {
$char_size = 3; // Which standard font size?
$char_height = 35; // How tall is a line?
$char_width = 7; // How wide is each character?
// Determine width based on string length
$width = strlen($msg)*$char_width+30;
// Create a blank image to draw on