Skip to content

Instantly share code, notes, and snippets.

@victorb
Created November 3, 2020 17:00
#! /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