From 5d73e315e9282e13b33ae2c1eccced554d595bd6 Mon Sep 17 00:00:00 2001 From: Christian Mueller Date: Sun, 5 Jan 2014 19:38:25 +0100 Subject: [PATCH] get-signature implemented --- src/NoteHub/api.clj | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/NoteHub/api.clj b/src/NoteHub/api.clj index 159e6ca..f9be74c 100644 --- a/src/NoteHub/api.clj +++ b/src/NoteHub/api.clj @@ -1,10 +1,24 @@ -(ns NoteHub.api) +(ns NoteHub.api + (:require [NoteHub.storage :as persistance])) (def api-version "1.0") -(defn get-signature [& args]) +(defn- create-response + ([success] { :success success }) + ([success message] + (assoc (create-response success) :message message))) + +(let [md5Instance (java.security.MessageDigest/getInstance "MD5")] + (defn get-signature + "Returns the MD5 hash for the concatenation of all passed parameters" + [& args] + (let [input (apply str args)] + (do (.reset md5Instance) + (.update md5Instance (.getBytes input)) + (.toString (new java.math.BigInteger 1 (.digest md5Instance)) 16))))) + +(defn get-note [noteID]) (defn post-note [& args]) -(defn get-note [& args]) (defn update-note [& args]) (defn register-publisher [& args]) (defn revoke-publisher [& args])