 (defn- bytes [str]
   (.getBytes str "UTF-8"))
 
-(defn- base64 [str]
-  (Base64/encodeBase64String str))
+(defn- base64 [b]
+  (Base64/encodeBase64String b))
 
-(defn- get-mac [key]
-  (let [signing-key (SecretKeySpec. (bytes key) hmac-sha256-algorithm)
+(defn- get-mac []
+  (let [signing-key (SecretKeySpec. (bytes (aws-secret)) hmac-sha256-algorithm)
         mac (Mac/getInstance hmac-sha256-algorithm)]
     (.init mac signing-key)
     mac))
 
 (defn- calculate-hmac [data]
   (try
-    (let [mac (get-mac (aws-secret))
+    (let [mac (get-mac)
           raw-mac (.doFinal mac (bytes data))]
       (base64 raw-mac))
     (catch Exception e

   [javax.crypto.spec SecretKeySpec]
   [org.apache.commons.codec.binary Base64]
   [org.joda.time DateTime DateTimeZone]))


(def ^:const hmac-sha256-algorithm  "HmacSHA256")
(def ^:const new-line "\n")

       (generate-query-string query-params)))

(defn- generate-signature [method uri query-params]
  (let [query-params (into (sorted-map) query-params)
        url (URL. uri)
        host (lower-case (.getHost url))
        path (get-path url)
        data (url-to-sign method host path query-params)]
