Skip to content

Instantly share code, notes, and snippets.

@refactor
Last active May 24, 2023 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save refactor/750d7f4de4179879b7611216a5c997a6 to your computer and use it in GitHub Desktop.
Save refactor/750d7f4de4179879b7611216a5c997a6 to your computer and use it in GitHub Desktop.
> io_lib:format("~2.16.0B", [15]).
0F
> io_lib:format("~2.16.#b", [15]).
"#f"
> io_lib:format("~2.2.#b", [1]).
"#1"
> io_lib:format("~2.2.#b", [2]).
"10"
> io_lib:format("~8.2.0b", [3]).
"00000011"
> io_lib:format("~8.2.*b", [$*, 3]).
"******11"
> HV = crypto:hash(sha3_512, Bin).
> << <<(binary:list_to_bin(io_lib:format("~2.16.0b", [X])))/binary>> || <<X>> <= HV>>.
> H = binary:encode_hex(HV, lowercase).
> HV == binary:decode_hex(H).
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment