Skip to content

Clj-crypto is a wrapper for Bouncy Castle which allows you to easily use cryptography in your clojure app.

Notifications You must be signed in to change notification settings

macourtney/clj-crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Clj-crypto is a wrapper for Bouncy Castle which allows you to easily use cryptography in your clojure app.

Resources

Stars

Watchers

Forks

Packages

No packages published