Boost logo

Boost Users :

Subject: [Boost-users] Base16, 32, 64 Encoding / Decoding
From: Jeff Dunlap (jeff_j_dunlap_at_[hidden])
Date: 2008-12-18 17:59:43


I had really hoped to find something in boost but didn't. I looked on the
web and found various routines to encode data and came across a pretty
complete library that encodes and decodes base16, base32, base64. Most are
for either base16 or base32 but CyoEncode by Cyotec covers the three of them
and the source code is available online.

The function parameters seem very unfamiliar to me, for example:

unsigned long Base32Encode( void* dest, const void* src, unsigned long
size );
unsigned long Base32Decode( void* dest, const void* src, unsigned long
size );

There are no samples online so I don't know how to use it. Since I don't
understand those function params above, I just came up with the code below
(seems to encode and decode base64 correctly but not for base32, base16:

// encode
char * buf1;
buf1 = new char [100];
const std::string s = "1010";
CyoEncode::Base16Encode(buf1, s.c_str(), s.length()); //
CyoEncode::Base16EncodeGetLength(s.length()));
std::cout << "[" << buf1 << "]" << std::endl;

// decode
char * buf2;
buf2 = new char [100];
const std::string s2(buf1);
CyoDecode::Base16Decode(buf2, s2.c_str(), s2.length());
std::cout << "[" << buf2 << "]" << std::endl;

Can someone review the Base32Encode params and let me know how this is
really supposed to be used?

Thank you very much,

Jeff

--
ELKNews FREE Edition - Empower your News Reader! http://www.atozedsoftware.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net