Skip to content

Instantly share code, notes, and snippets.

View jtdowney's full-sized avatar

John Downey jtdowney

View GitHub Profile
require 'openssl'
key = OpenSSL::PKey::DSA.generate 1024
puts key.to_pem
cert = OpenSSL::X509::Certificate.new
cert.version = 2
cert.serial = 1
cert.subject = OpenSSL::X509::Name.new [['CN', 'Test CA']]
cert.issuer = cert.subject
@jtdowney
jtdowney / chat.go
Created October 25, 2012 12:59
Simple Chat Server
package main
import (
"bufio"
"fmt"
"io"
"log"
"net"
)
@jtdowney
jtdowney / ecb.md
Last active September 1, 2020 20:06
Create ECB pattern images

This gist describes how to use the ImageMagick and OpenSSL command line tools to encrypt an image using ECB mode.

First we need to gather some information about the original image. This will tell us what size to use in our final step.

$ identify Braintree.png
Braintree.png PNG 898x229 898x229+0+0 8-bit sRGB 65KB 0.000u 0:00.000

Looks like the image is 898x229.

Next we need to convert the image into the RGBA format. This is a simple binary format that only contains uncompressed pixel data and no meta information, like image dimensions.

Keybase proof

I hereby claim:

  • I am jtdowney on github.
  • I am jtdowney (https://keybase.io/jtdowney) on keybase.
  • I have a public key whose fingerprint is 64A1 17F1 DED3 DD44 E9A2 57C9 D297 3F2A F0FB D951

To claim this, I am signing this object:

#![feature(slice_patterns)]
fn main() {
let foo: Vec<i32> = (1..10).collect();
match foo.as_slice() {
[first, rest..] => println!("{:?} :: {:?}", first, rest),
[] => println!("empty"),
}
}
package com.jtdowney;
import javax.net.ServerSocketFactory;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.security.KeyStore;
@jtdowney
jtdowney / day1.rs
Last active December 1, 2017 16:11
#[macro_use]
extern crate error_chain;
mod errors {
error_chain! {
foreign_links {
Io(::std::io::Error);
}
}
}
@jtdowney
jtdowney / part1.rs
Last active December 3, 2017 18:05
day 3
use std::env;
#[derive(Debug)]
enum Direction {
Left,
Right,
Up,
Down,
}
extern crate itertools;
use itertools::Itertools;
use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::result;
use std::str;
fn part1(input: &[Vec<String>]) {
use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::{Read, BufReader};
use std::str;
fn solve(mut input: Vec<u32>) {
let length = input.len();
let mut count = 0;
let mut history = HashMap::new();