replikativ / geheimnis

Cross-platform cryptography between cljs and clj.
Eclipse Public License 1.0
35 stars 2 forks source link

geheimnis

Implementation of cross-platform (clj, cljs) cryptography. The library supports AES/CBC/Pkcs7Padding with a 256 bit key and RSA with arbitrary keysize, as well as simple MD5 hashing. If you need something which is not provided, please open an issue. While geheimnis is not supposed to cover all cryptographic options like OpenSSL compatibility with a big set of chiffres, common and useful algorithms to do standard public-private key solutions should be provided with a solid implementation. geheimnis is supposed to be batteries included on Clojure level, so doing the right thing should be easy.

This library is still very young, but encryption methods work between platforms and are initialized with proper upstream/documented parameters. If you hit any problems, open an issue.

Usage Gitter

Add this to your leiningen project's dependencies: Clojars Project

(require '[geheimnis.rsa :refer [gen-key encrypt decrypt]]
         '[geheimnis.base64 :refer [encode decode]])

(def rsa-key (gen-key 1024))

(decrypt rsa-key (encrypt rsa-key (BigInteger. "123")))

(encode (:pub-key rsa-key)) ;; => #geheimnis/Base64 "AAECAwQFBgcICQ=="
(require '[geheimnis.aes :refer [encrypt decrypt]])

(decrypt "s3cr3T" (encrypt "s3cr3T" (byte-array (range 10))))
(require '[geheimnis.md5 :refer [encode]])

(encode "geheimnis") ;; => "525e92c6aa11544a2ab794f8921ecb0f" 

Clojurescript Testing

Make sure karma and launcher for testing in your favourite browser is installed:

 npm install karma karma-firefox-launcher karma-chrome-launcher karma-safari-launcher  karma-cljs-test --save-dev

Test in your preferred browser by running

lein doo firefox browser-test

TODO

License

Copyright © 2016-2017 Christian Weilbach, Konrad Kühne

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.