Skip to content

Instantly share code, notes, and snippets.

View developer-guy's full-sized avatar
🐾
Every artifact can be verifiably traced to Source Code and Hardware

Batuhan Apaydın developer-guy

🐾
Every artifact can be verifiably traced to Source Code and Hardware
View GitHub Profile
@developer-guy
developer-guy / rsa_sign.go
Created April 15, 2021 20:00 — forked from Grrrben/rsa_sign.go
Signing and Verifying using Golang RSA
// Sign returns a signature made by combining the message and the signers private key
// With the r.Verify function, the signature can be checked.
func (r *RsaIdentity) Sign(msg []byte) (signature []byte, err error) {
hs := r.getHashSum(msg)
signature, err := rsa.SignPKCS1v15(rand.Reader, r.private, crypto.SHA256, hs)
return
}
@developer-guy
developer-guy / sign_and_verify_test.go
Created April 15, 2021 19:59 — forked from nilsmagnus/sign_and_verify_test.go
Sign a message and verify signature with go using PKCS1. Compatible with java (SHA256withRSA)
package main
import (
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"encoding/base64"
"testing"
)
package main
import (
"fmt"
"log"
"os"
"os/signal"
"github.com/iovisor/gobpf/bcc"
)
@developer-guy
developer-guy / Certificates.go
Created March 10, 2021 07:59 — forked from Mattemagikern/Certificates.go
Create x509 certificate chain using Golang. Root CA, Designated CA, server CA
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"math/big"
@developer-guy
developer-guy / piping.go
Created March 5, 2021 11:45 — forked from kylelemons/piping.go
piping exec.Cmd in golang (example sorts all regular files under a directory by their extension)
package main
import (
"bytes"
"exec"
"log"
"os"
)
// Pipeline strings together the given exec.Cmd commands in a similar fashion
@developer-guy
developer-guy / Dockerfile
Created March 4, 2021 19:44 — forked from kszarek/Dockerfile
Go application on docker scratch image
# This is the first stage, for building things that will be required by the
# final stage (notably the binary)
FROM golang
# Copy in just the go.mod and go.sum files, and download the dependencies. By
# doing this before copying in the other dependencies, the Docker build cache
# can skip these steps so long as neither of these two files change.
COPY go.mod go.sum ./
RUN go mod download
@developer-guy
developer-guy / Dockerfile1
Created March 4, 2021 19:37 — forked from xeoncross/Dockerfile1
Examples of using multi-stage builds with docker and Go to reduce the final image size / attack surface.
# Sample from @citizen428 https://dev.to/citizen428/comment/6cmh
FROM golang:alpine as build
RUN apk add --no-cache ca-certificates
WORKDIR /build
ADD . .
RUN CGO_ENABLED=0 GOOS=linux \
go build -ldflags '-extldflags "-static"' -o app
FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt \
@developer-guy
developer-guy / tar_helper.go
Created February 10, 2021 10:33 — forked from maximilien/tar_helper.go
Creating tarball in Golang
package tar_helper
import (
"archive/tar"
"compress/gzip"
"errors"
"fmt"
"io"
"io/ioutil"
"os"
@developer-guy
developer-guy / .gitlab-ci.yml
Created February 9, 2021 12:21 — forked from plajjan/.gitlab-ci.yml
Git automation stuff
image: gitlab.dev.terastrm.net:4567/terastream/cisco-nso/ci-cisco-nso:4.2.3
stages:
- build
- mr-robot
variables:
NCS_VERSION: "4.2.3"
DOCKER_REGISTRY: "gitlab.dev.terastrm.net:4567/terastream/cisco-nso"
TARGET_REGISTRY: "repo.dev.terastrm.net:5000/"
@developer-guy
developer-guy / jq-cheetsheet.md
Created February 1, 2021 12:51 — forked from olih/jq-cheetsheet.md
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq