Last active
May 19, 2016 22:27
-
-
Save octaviogb/7eba10979a3c017daa4bc915afc38069 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns sphynx.core | |
(:use [amazonica.aws.kms :as kms] | |
[amazonica.core :as aws] | |
[nio.core :as nio] | |
[clojure.data.codec.base64 :as b64])) | |
(aws/defcredential ...) | |
(defn toBase64' [content] | |
(b64/encode (.getBytes content))) | |
(defn fromBase64' [content] | |
(b64/encode (.getBytes content))) | |
(defn byte-buffer' [content] | |
(nio/byte-buffer content)) | |
(defn encrypt' [content] | |
(kms/encrypt :keyId "arn:aws:kms:us-east-1::..." | |
:plaintext content)) | |
(defn decrypt' [content] | |
(kms/encrypt :keyId "arn:aws:kms:us-east-1::..." | |
:plaintext content)) | |
(defn encrypt-data [data] | |
(nio/buffer-to-array | |
(:ciphertext-blob | |
(encrypt' | |
(byte-buffer' | |
(toBase64' data)))))) | |
(defn decrypt-data [data] | |
(nio/buffer-to-array | |
(:ciphertext-blob | |
(decrypt' | |
(byte-buffer' | |
(toBase64' data)))))) | |
(defn get-encrypt-string [data] | |
(String. | |
(toBase64' | |
(String. data)))) | |
(defn -main [& args] | |
(println (encrypt ""))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment