Skip to content

Instantly share code, notes, and snippets.

View helloworld-cat's full-sized avatar

HelloWorld.cat helloworld-cat

View GitHub Profile
@mperham
mperham / gist:5f492a2233ed44d1bb2b
Last active April 16, 2024 12:31
Golang high-level crypto APIs

Go has a number of low-level crypto APIs which check off marketing bullet-points (got FIPS supprt, check!) but is missing an high-level API usable by mere mortal programmers. Imagine you want to create a document, sign it and verify that document later. Now check out Go's crypto APIs and give up in frustration after an hour of Googling.

The API should encapsulate a half-dozen common operations and make them as easy as possible. Avoid choice where possible, just pick something reasonably secure in 2014 for me and use it! I'm speaking specifically of a few basic actions (yes, this API is very naive/non-idiomatic), call it crypto/easy:

  • Create me a public/private key pair and save it to the filesystem.
// create and persist a keypair to the current directory.
// this is just a one-time operation, now we have a keypair to use.
easy.CreateKeyPair()
@rbackhouse
rbackhouse / V8JavaBridgeExample.java
Created March 20, 2011 22:29
Example demonstrating using the V8 Java Bridge to run javascript with a callback into java
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import org.dojotoolkit.json.JSONParser;
import org.dojotoolkit.json.JSONSerializer;
import org.dojotoolkit.rt.v8.V8Exception;
import org.dojotoolkit.rt.v8.V8JavaBridge;