Skip to content

Instantly share code, notes, and snippets.

View ruanbekker's full-sized avatar
🇿🇦

Ruan Bekker ruanbekker

🇿🇦
View GitHub Profile
@ruanbekker
ruanbekker / decrypt.py
Created April 6, 2019 20:37
Python Encryption / Decryption tool using NACL and SimpleCrypt
import argparse
import simplecrypt
import nacl.secret
import nacl.utils
import nacl.pwhash
import base64
import random
import uuid
import sys
@ruanbekker
ruanbekker / vault_api_app_users.md
Last active January 22, 2024 07:53
Vault API Usage: Provision App Keys to Create KV pairs
@ruanbekker
ruanbekker / vault_api_transit_secrets.md
Created April 7, 2019 16:51
Vault: Create Secrets with Vaults Transits Secret Engine

Description

Vault's transit secrets engine handles cryptographic functions on data-in-transit. Vault doesn't store the data sent to the secrets engine, so it can also be viewed as encryption as a service

Enable:

Enable transit secret engine using the /sys/mounts endpoint:

@ruanbekker
ruanbekker / vault_api_tools.md
Created April 7, 2019 16:57
Vault Tools using the API

Create a random base64 hash

$ curl -s -H "X-Vault-Token: ${VAULT_TOKEN}"  -XPOST --data '{"format": "base64", "bytes": 32}' http://127.0.0.1:8200/v1/sys/tools/random/64 | jq
{
  "request_id": "d32a5281-35ec-1e8d-1d24-373daaaa6718",
  "lease_id": "",
  "renewable": false,
  "lease_duration": 0,
  "data": {
@ruanbekker
ruanbekker / readme_setup.md
Last active January 22, 2024 07:53
Vault Server with Docker and Setting Up

Create the directory structure:

touch docker-compose.yml
mkdir -p volumes/{config,file,logs}

Populate the vault config vault.json:

@ruanbekker
ruanbekker / rest_api.go
Created April 17, 2019 09:50
Rest API in Golang
import (
"encoding/json"
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
"github.com/rs/xid"
)
@ruanbekker
ruanbekker / golang_split_strings.go
Last active January 22, 2024 07:53
Golang: Split strings by character
package main
import (
"fmt"
"os"
"strings"
)
func main() {
for _, envs := range os.Environ() {
@ruanbekker
ruanbekker / setup_golang_app.md
Last active January 22, 2024 07:53
Setup a Basic Golang App

Runtime environment on alpine:

$ docker run -it alpine sh
apk add --no-cache bash
bash

Build environment:

@ruanbekker
ruanbekker / basic_go_exporter.md
Created February 5, 2020 12:51
Basic Prometheus Exporter in Go
docker run -it golang:alpine sh
mkdir src/github.com/ruanbekker/myfirstexporter -p
cd src/github.com/ruanbekker/myfirstexporter/
vi main.go
vi collector.go
@ruanbekker
ruanbekker / docker_logging_fluentd.md
Created February 25, 2020 10:27
Docker Logging with FluentD
<source>
  @type forward
</source>

<match app.**>
  type stdout
</match>

<filter app2.**>