Skip to content

Instantly share code, notes, and snippets.

@sdorra
sdorra / JGitTest.java
Created July 22, 2020 05:02
Sign and verify commits with JGit
import org.bouncycastle.bcpg.ArmoredInputStream;
import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.bouncycastle.bcpg.BCPGOutputStream;
import org.bouncycastle.bcpg.HashAlgorithmTags;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPObjectFactory;
import org.bouncycastle.openpgp.PGPPrivateKey;
import org.bouncycastle.openpgp.PGPPublicKey;
@sdorra
sdorra / cert.go
Created July 3, 2016 20:56
Certificate generation in Go
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"log"
"math/big"
@sdorra
sdorra / generate-keys.sh
Created June 6, 2021 19:55
ecdsa: sign in go, verify in node
openssl ecparam -name prime256v1 -genkey -noout -out private.pem
openssl ec -in private.pem -pubout -out public.pem
@sdorra
sdorra / App.java
Created June 15, 2016 20:27
Jackson sample with deep field filter
public class App {
public static void main(String[] args) {
Type type = new Type("hg", "Mercurial");
Repository repository = new Repository("42", "scm", type, "SCM-Manager", "SCM-Manager Repository Hosting");
System.out.println(JSON.asString(repository));
System.out.println(JSON.asString(repository, "id", "desc"));
System.out.println(JSON.asString(repository, "id", "name", "type", "type.name", "displayName"));
}
@sdorra
sdorra / keys.go
Created April 17, 2016 19:31
Golang RSA Key Generation
/*
* Genarate rsa keys.
*/
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
@sdorra
sdorra / app.go
Created April 6, 2016 19:48
SSEvents with golang
package main
import (
"io"
"strconv"
"time"
"github.com/gin-gonic/gin"
)