/encrypted-config

Encrypt configuration library for Clojure

Primary LanguageClojureEclipse Public License 1.0EPL-1.0

encrypted-config

https://img.shields.io/clojars/v/encrypted-config.svg https://jarkeeper.com/agilecreativity/encrypted-config/status.svg

Easy encrypted your configuration in Clojure using the power of buddy.

Basic Usage

What you will need to use this library

-

Use in your project

Leiningen/Boot

[encrypted-config "0.1.1"]

Gradle

compile "encrypted-config:encrypted-config:0.1.1"

Maven

<dependency>
  <groupId>encrypted-config</groupId>
  <artifactId>encrypted-config</artifactId>
  <version>0.1.1</version>
</dependency>

Basic Usage:

Encrypt a given text

;; To encrypted a given input-text using the secret-key
(str->encrypted input-text secret-key)

;; You will get back the map of
;; {:encrypted-key  <key-generated-by-the-system>
;;  :encrypted-text <encrypted-text-that-you-can-use>}

Decrypt value that previously encrypted

(str->decrypted encrypted-text encrypted-key secret-key)

Example Usages

(let [input-text "MyP@ssword!"
      secret-key "MySec$tKey@"
      {:keys [encrypted-key
              encrypted-text]}
      (str->encrypted input-text secret-key)
      ;; Now let's decrypt the text we have just encrypted
      decrypted-text (str->decrypted encrypted-text
                                     encrypted-key
                                     secret-key)]
  (do
    (println (str "FYI: input-text     : " input-text))
    (println (str "FYI: secret-key     : " secret-key))
    (println (str "FYI: encrypted-key  : " encrypted-key))
    (println (str "FYI: encrypted-text : " encrypted-text))))

Your result will be like:

FYI: input-text     : MyP@ssword!
FYI: secret-key*    : MySec$tKey@
FYI: encrypted-key* : b0ed81af1e42b826ccdcabc3fa059d0c
FYI: encrypted-text : 3e8a19218245b48c5f546c902c75deb98077d7e2d7030afde9f0b10a8e3a6bb0

So you can safely store the encrypted-text in the property file and decrypted it back safely.

Links

License

Copyright © 2017 Burin Choomnuan

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