Skip to content
Clj-crypto is a wrapper for Bouncy Castle which allows you to easily use cryptography in your clojure app.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/clj_crypto
test/clj_crypto/test
.gitignore
README.md
project.clj

README.md

clj-crypto

The clj-crypto library is a Clojure wrapper for the Java Bouncy Castle encryption library.

Installation

clj-crypto is available is available as a Maven artifact from Clojars Project

To use, simply add [clj-crypto "1.0.2"] to your project.clj

Usage

(:require [clj-crypto.core :as crypto])

To read your pkcs12 certificate store:

(def keypair (crypto/get-key-pair-pkcs12 pkcs12-store passwd alias))

This will use the 'Bouncy Castle' as your crypto-provider. If you want to use another, you can supply that as well like so:

(def keypair (crypto/get-key-pair-pkcs12 pkcs12-store passwd alias crypto/sun-provider)) ; use SunJSSE

To obtain your private-key from a key-pair, drop in to java, like so:

(def private-key (.getPrivate keypair)

To sign a message with your private key:

(crypto/sign private-key msg
             crypto/sha256-signature-algorithm
             crypto/default-provider)

Of course, you also have your standard functions for base64 encoding

(crypto/decode-base64 (crypto/encode-base64-as-str (.getBytes "sikrit")))

License

Copyright (C) 2012 Matt Courtney

Distributed under the Eclipse Public License, the same as Clojure.

You can’t perform that action at this time.