Is there something in Boost that can help me decode hex strings into binary form? For example hexadecimal strings that contain MD5 hashes. S.
On Sun, 25 Nov 2007 21:13:15 +0100, "Stefan Arentz"
Is there something in Boost that can help me decode hex strings into binary form? For example hexadecimal strings that contain MD5 hashes.
S.
Yoy may divide the hex string into shorter parts that fit within un unsigned long and read them into unsigned long using std::istream, then convert them into std::bitset or boost::dynamic_bitset, and further convert them into binary representation using std::ostream. As you seee, you may do it only with standara library components, but ther is no direct way to do it, you must go through unsigned longs always. Bes regards, Zara
On 11/26/07, Zara
On Sun, 25 Nov 2007 21:13:15 +0100, "Stefan Arentz"
wrote: Is there something in Boost that can help me decode hex strings into binary form? For example hexadecimal strings that contain MD5 hashes.
S.
Yoy may divide the hex string into shorter parts that fit within un unsigned long and read them into unsigned long using std::istream, then convert them into std::bitset or boost::dynamic_bitset, and further convert them into binary representation using std::ostream.
Sure. I'm doing the conversion manually now, but I had hoped for some kind of 'codec' component in Boost. Now it's hex but maybe later I need to decode/encode base64 for example. It sounds like a good candidate for a future library. S.
Stefan Arentz wrote:
Sure. I'm doing the conversion manually now, but I had hoped for some kind of 'codec' component in Boost. Now it's hex but maybe later I need to decode/encode base64 for example. It sounds like a good candidate for a future library.
S.
Note that the serialization library has "dataflow iterators" which are used to convert to base64 and back again. I'm sure a minor variation of this could be used for hex data of arbitrary length. Robert Ramey
participants (3)
-
Robert Ramey
-
Stefan Arentz
-
Zara