Hi Bialecki, It always better use library which provided by MAC OS.
Thanks& regards, Joby Abraham. On Thu, Apr 15, 2010 at 02:17, Jean-Daniel Dupas <devli...@shadowlab.org>wrote: > Google provide some class to do that too. > > See GTMBase64 classes at > http://code.google.com/p/google-toolbox-for-mac/source/browse/#svn/trunk/Foundation > > Le 14 avr. 2010 à 22:00, joby abraham a écrit : > > > Hi Bialecki, > > > > for base64 encoding/decoding you can use openSSL Library which providing > by > > MAC OS. > > > > I can give you code snippets for encoding and decoding string. > > > > #include <openssl/bio.h> > > #include <openssl/evp.h> > > > > - (NSString *)base64EncodedString > > { > > // Construct an OpenSSL context > > BIO *context = BIO_new(BIO_s_mem()); > > > > // Tell the context to encode base64 > > BIO *command = BIO_new(BIO_f_base64()); > > context = BIO_push(command, context); > > > > // Encode all the data > > BIO_write(context, [self bytes], [self length]); > > BIO_flush(context); > > > > // Get the data out of the context > > char *outputBuffer; > > long outputLength = BIO_get_mem_data(context, &outputBuffer); > > NSString *encodedString = [NSString > > stringWithCString:outputBuffer > > length:outputLength]; > > > > BIO_free_all(context); > > > > return encodedString; > > } > > > > > > + (NSData *)dataByDase64DecodingString:(NSString *)decode > > { > > decode = [decode stringByAppendingString:@"\n"]; > > NSData *data = [decode dataUsingEncoding:NSASCIIStringEncoding]; > > > > // Construct an OpenSSL context > > BIO *command = BIO_new(BIO_f_base64()); > > BIO *context = BIO_new_mem_buf((void *)[data bytes], [data length]); > > > > // Tell the context to encode base64 > > context = BIO_push(command, context); > > > > // Encode all the data > > NSMutableData *outputData = [NSMutableData data]; > > > > #define BUFFSIZE 256 > > int len; > > char inbuf[BUFFSIZE]; > > while ((len = BIO_read(context, inbuf, BUFFSIZE)) > 0) > > { > > [outputData appendBytes:inbuf length:len]; > > } > > > > BIO_free_all(context); > > [data self]; // extend GC lifetime of data to here > > > > return outputData; > > } > > > > > > 2010/4/14 Bartosz Bialecki <biale...@hqs.de> > > > >> Hi everyone, > >> I have some problem. I'm writing a web service client and one of my xml > >> request require a data encoded as base64Binary. I'm using NSData type in > my > >> application but data are encoded as base64. Do you know any solution? > >> > >> Best regards, > >> Bartosz Bialecki > >> _______________________________________________ > >> > >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > >> > >> Please do not post admin requests or moderator comments to the list. > >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com > >> > >> Help/Unsubscribe/Update your Subscription: > >> > >> > http://lists.apple.com/mailman/options/cocoa-dev/jobyabraham1983%40gmail.com > >> > >> This email sent to jobyabraham1...@gmail.com > >> > > > > > > > > -- > > Thanks & Regards, > > Joby Abraham. > > _______________________________________________ > > > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > > > Please do not post admin requests or moderator comments to the list. > > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > > > Help/Unsubscribe/Update your Subscription: > > > http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org > > > > This email sent to devli...@shadowlab.org > > -- Jean-Daniel > > > > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com