   "Encode a bytes array to base64."
   [#^bytes data]
   (let [codec (Base64. true)]
-    (.encodeToString codec data)))
+    (trim (.encodeToString codec data))))
 
 (defn base64->bytes
   "Decode from base64 to bytes."

  [^String s]
  (let [codec (Base64. true)
        data  (str->bytes s)]
    (.encodeToString codec data)))

(defn base64->str
  "Decode from base64 to string."

(ns buddy.crypto.core
  "Basic crypto primitives that used for more high
  level abstractions."
  (:require [clojure.string :refer [trim]])
  (:import (org.apache.commons.codec.binary Base64 Hex)
           (javax.crypto Mac)
           (javax.crypto.spec SecretKeySpec)
