def s := "hi"
def encode (s : String) := s.toList.map (λ x ↦
let bx := x.toUInt8.toBitVec
List.range 8
|>.map λ y ↦
if bx.getMsbD y then " " else "")
|>.flatten
|> "f".intercalate
def decode (s : String) := s.splitOn "f"
|>.map (· == " ")
|>.foldl (λ (a, b) x ↦
if b.length = 7 then
(a ++ (b ++ [x]
|> BitVec.ofBoolListBE
|>.toNat
|> Char.ofNat).toString, [])
else (a, b ++ [x])) ("", [])
|>.1
#eval encode s |> decode