Created
November 3, 2020 17:00
-
-
Save victorb/dca8a79335a87cadf1cbef063bdd2c5c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#! /usr/bin/env bb | |
(import '[java.io ByteArrayOutputStream | |
ByteArrayInputStream | |
PushbackInputStream]) | |
(require '[clojure.pprint :refer [pprint]]) | |
(require '[bencode.core :refer [write-bencode | |
read-bencode]]) | |
(defn read-bc [s] | |
(-> (.getBytes s "UTF-8") | |
ByteArrayInputStream. | |
PushbackInputStream. | |
read-bencode)) | |
(defn write-bc [c] | |
(-> (doto (ByteArrayOutputStream.) | |
(write-bencode c)) | |
.toString)) | |
(pprint (read-bc "d2:id7:unknown11:new-session36:7935c405-6ef9-4883-8432-69ce095585777:session4:none6:statusl4:doneee")) | |
(pprint | |
(write-bc {:op :clone})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment