Starting slowly and questions...
Fri Jul 2 16:25:34 CEST 2004
> Digest = erlang:md5(Contents).
> io:format("~.16b\n", [Digest]).
> I'd like to get it to output something like:
> maybe there is a function to turn a arbitrary length binary into a hex
> string but
As far as I know, there is no such function in OTP.
The b control sequence is for integers (not binaries), so if you need to
dump out reasonably short binaries, you might do something like...
MyBinary = some_function(SomeArguments,...),
MyBinaryBitSize = 8 * size(MyBinary),
<<MyInteger:MyBinaryBitSize/integer>> = MyBinary,
io:format("~*.16.0b\n", [size(MyBinary) * 2, MyInteger]).
...but something like the following is much more erlangish...
dump_binary(IODevice, <<>>) ->
io:format(IODevice, "~n", );
dump_binary(IODevice, <<Octet, Rest/binary>>) ->
io:format(IODevice, "~2.16.0b\n", [Octet]),
...and in the case you want to group the bytes in some way, it is easy
to accomplish with such a function.
More information about the erlang-questions