-
-
Save marcandrefontaine/103e4d2200e19eb6d5a8 to your computer and use it in GitHub Desktop.
b64+inflate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns mf | |
(:require [clojure.data.codec.base64 :as b64]) | |
(:import (java.util.zip Inflater))) | |
(defn decompress-content [content] | |
(let [decoded (b64/decode (.getBytes content)) | |
buffer-size (* 2 (count decoded)) | |
result (byte-array buffer-size) | |
inflater (Inflater.) | |
] | |
(. inflater setInput decoded 0 (count decoded)) | |
(loop [return ""] | |
(if (. inflater finished) | |
return | |
(let [nb (. inflater inflate result 0 buffer-size)] | |
(recur (str return (String. result 0 nb "UTF-8"))) | |
) | |
) | |
) | |
)) | |
(decompress-content "eJzzt7KwUiouSXHOSSwuVrIysqoutjK2UiosqVSyzrQyNDAwsC62MgUqyUxJLVYCss2slFz8Q518XJWsawEyGRG/") | |
=> "O:8:\"stdClass\":2:{s:3:\"qty\";i:1000;s:5:\"sides\";s:6:\"DOUBLE\";}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment