Re: Base64 encoding on Leopard
Re: Base64 encoding on Leopard
- Subject: Re: Base64 encoding on Leopard
- From: Philip Aker <email@hidden>
- Date: Tue, 20 Nov 2007 07:03:03 -0800
On 2007-11-20, at 02:46, Quinn wrote:
At 21:06 -0500 19/11/07, Jaime Magiera wrote:
- What are other folks using to get Base64 data?
That's a good question. There are lots of different
implementations in the system, but it's hard to recommend one
that's truly appropriate. For something as trivial as base64, I'd
probably just write it myself (or cut'n'paste the code from an
appropriate source, that is, one with a permissive licence).
btw I filed a bug <rdar://problem/5608839> requesting a nice,
general purpose base64 encode/decode API.
Thanks,
Coincidentally, I have submitted <radr://5608962> CFData Base64
encode/decode functions
Any chance in it could be in CoreFoundation like a CFDataEncode/
DecodeBase64?
static CFDataRef CFData_EncodeToBase64( CFAllocatorRef theAllocator,
CFDataRef theData, const Boolean doNewlines ) {
CFDataRef data = NULL;
if( theData != NULL ) {
char *encoded_bytes = NULL;
CFIndex length = 0;
BIO *biomem = BIO_new( BIO_s_mem() );
BIO *base64 = BIO_new( BIO_f_base64() );
if( ! doNewlines ) {
BIO_set_flags( base64, BIO_FLAGS_BASE64_NO_NL );
}
biomem = BIO_push( base64, biomem );
BIO_write( biomem, CFDataGetBytePtr( theData ), CFDataGetLength
( theData ) );
BIO_flush( biomem );
length = BIO_get_mem_data( biomem, &encoded_bytes );
data = CFDataCreate( theAllocator, (UInt8 *)encoded_bytes, length );
BIO_free_all( biomem );
}
return data;
}
Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden