package multibase
Self-describing base encodings
Install
Dune Dependency
Authors
Maintainers
Sources
multibase-0.1.0.tbz
sha256=b46509dd92fef15d2b78a4c831fa7c2caeef17e454f621711a2700dd82a15a95
sha512=28fcd03934e4de642bf1afaff9cb1e2563345b014601dcbb3e2bfefae8b88b2cda9c738e970bf339bd87bcab7b0b26cfc89bd71585a6ade00ac7ac0a7d92b504
README.md.html
ocaml-multibase
A library providing self-identifying base encodings as per the multibase. Take the following encoded string. Not only can be decode it without specifying a base-encoding scheme, we also get that scheme back.
let encoded = "T9T1M2RBC41KN6837E9IM2T11"
The Base.decode
function will return either the encoding scheme along with the decoded string, or an error.
# Multibase.decode encoded;;
- : (Multibase.Encoding.t * string,
[ `Msg of string | `Unsupported of Multibase.Encoding.t ])
result
= Ok (`Base32hexpadupper, "OCaml is great!")
So this string was encoded using Base32 with the extended hexadecimal alphabet in upper-case. We can just as easily put it back the way it was.
# let encoded_ = Multibase.encode `Base32hexpadupper "OCaml is great!";;
val encoded_ :
(string, [ `Msg of string | `Unsupported of Multibase.Encoding.t ]) result =
Ok "T9T1M2RBC41KN6837E9IM2T11"
# String.equal encoded (Result.get_ok encoded_);;
- : bool = true
Note that the main encode
function will let you specify all possible encodings as per the specification. However, encode_t
narrows this to the support encodings of this library, hence it won't return `` Unsupported
.
# let encoded_ = Multibase.encode_t `Base32hexpadupper "OCaml is great!";;
val encoded_ : (string, [ `Msg of string ]) result =
Ok "T9T1M2RBC41KN6837E9IM2T11"
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>