Hi Jeff,

You need to use the Base??EncodeGetLength() functions first, allocate a buffer of the required size, then use the Base??Encode() function:

const char* source = "...";
unsigned long sourceSize = strlen( source );
unsigned long size = Base32EncodeGetLength( sourceSize );
char* dest = new char[ size+1 ]; //+1 for null terminator
Base32Encode( dest, source, sourceSize );

Regards,

Graham



2008/12/18 Jeff Dunlap <jeff_j_dunlap@yahoo.com>
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 mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users



--
"Facts do not cease to exist because they are ignored"
Aldous Huxley