Encodes String in base 64; returns a String. If not specified,
encoding is UTF-8 and line-length is nil.
(defn encode-str
"Encodes String in base 64; returns a String. If not specified,
encoding is UTF-8 and line-length is nil."
([s] (encode-str s "UTF-8" nil))
([^String s ^String encoding line-length]
(let [output (StringWriter.)]
(encode (ByteArrayInputStream. (.getBytes s encoding))
output *base64-alphabet* line-length)
(.toString output))))
Comments top
No comments for encode-str. Log in to add a comment.