Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
(defproject district0x/district-encryption "1.0.2-SNAPSHOT"
(defproject district0x/district-encryption "1.0.3-SNAPSHOT"
:description "Set of functions helpful for data encryption on blockchain based on public/private key"
:url "https://github.com/district0x/district-encryption"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[cljsjs/eccjs "0.3.1-0"]
[org.clojure/clojurescript "1.9.946"]]
:dependencies [[org.clojure/clojurescript "1.9.946"]]

:npm {:dependencies [[eccjs "0.3.1"]]}

Expand Down
11 changes: 4 additions & 7 deletions src/district/encryption.cljs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
(ns district.encryption
(:require
[cljsjs.eccjs :as eccjs]
["eccjs" :as ecc]
[goog.crypt.base64 :as base64]))

(when (and (exists? js/process) (= (str js/process) "[object process]")) ;; node environment
(set! js/ecc (js/require "eccjs")))

(defn generate-keypair []
(let [keypair (js->clj (.generate js/ecc (.-ENC_DEC js/ecc) 256))]
(let [keypair (js->clj (.generate ecc (.-ENC_DEC ecc) 256))]
{:public-key (get keypair "enc")
:private-key (get keypair "dec")}))

(defn encrypt [public-key content]
(.encrypt js/ecc public-key content))
(.encrypt ecc public-key content))

(defn decrypt [private-key content]
(.decrypt js/ecc private-key content))
(.decrypt ecc private-key content))

(defn encode-base64 [s]
(base64/encodeString s))
Expand Down