Skip to content

Instantly share code, notes, and snippets.

@cbluth
cbluth / golang_pipe_http_response.go
Created February 11, 2020 16:40 — forked from ifels/golang_pipe_http_response.go
golang pipe the http response
package main
import (
"io"
"net/http"
"os/exec"
)
var (
BUF_LEN = 1024
@cbluth
cbluth / readwrite.go
Created February 11, 2020 00:30 — forked from glinton/readwrite.go
Working example of one way to Read() large(ish) data (1MB) from a golang net.Conn
// Package main is intended to provide a working example of how to properly
// read from a net.Conn without losing data or integrity. The data is generated
// from alphabetical characters rather than simply rand to prevent the
// generation of an `EOF`
package main
import (
"crypto/md5"
"fmt"
"io"
@cbluth
cbluth / gist:556ac9c3bb882e22d470f5558ee31cb2
Created February 6, 2020 10:53 — forked from fiorix/gist:9664255
Go multicast example
package main
import (
"encoding/hex"
"log"
"net"
"time"
)
const (
@cbluth
cbluth / keypair.js
Created February 4, 2020 12:29
bittorrent proximity attack calculations
var EC = require('elliptic').ec;
var sprintf = require('sprintf');
var target = Buffer(32);
target.fill(0);
Buffer(process.argv[2], 'hex').copy(target);
var best = null;
var count = 0;
var ec = new EC('ed25519');
var start = Date.now();
@cbluth
cbluth / udp_client.go
Created January 28, 2020 01:30 — forked from reterVision/udp_client.go
A dummy UDP hole punching sample in Go
package main
import (
"encoding/json"
"fmt"
"log"
"net"
"os"
"time"
)
@cbluth
cbluth / 01-curl.go
Created January 23, 2020 23:50 — forked from jmoiron/01-curl.go
io.Reader & io.Writer fun
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func init() {
@cbluth
cbluth / aes256-gcm.go
Created January 21, 2020 14:14 — forked from kkirsche/aes256-gcm.go
AES-256 GCM Encryption Example in Golang
package example_test
import (
"crypto/aes"
"crypto/cipher"
"hex"
"io"
)
// AES-GCM should be used because the operation is an authenticated encryption
@cbluth
cbluth / aes-256-gcm.go
Created January 21, 2020 14:14 — forked from cannium/aes-256-gcm.go
golang aes-256-gcm
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/hex"
"fmt"
"io"
)
@cbluth
cbluth / cipher.go
Created January 21, 2020 14:14 — forked from dakait/cipher.go
AES-256 GCM Encryption/Decryption Example in Golang
package secure
import (
"crypto/aes"
"crypto/cipher"
"encoding/hex"
"fmt"
"crypto/sha512"
)
@cbluth
cbluth / tar_helper.go
Created December 3, 2019 22:46 — forked from maximilien/tar_helper.go
Creating tarball in Golang
package tar_helper
import (
"archive/tar"
"compress/gzip"
"errors"
"fmt"
"io"
"io/ioutil"
"os"