How to convert array of bytes to base64 String in iphone?

See code sample, Very self-explained ... cocoadev.com/index.pl?BaseSixtyFour Also check below SO post . Any base64 library on iphone-sdk?

Sorry I forgot to mention that I have used these links to convert string to base64. Here arrays are being converted to base 64 so I am not getting desired output :( – Dimple Panchal Jun 24 at 10:10 @Dimple Panchal:I suspect conversion issues anyway. Could you elaborate your process?

– Jhaliya Jun 24 at 10:13 In my code each code is converted to Bytes and then the entire byte array is converted to base 64 string. I tried converting individual string to base64 and then append it, but Its not working :( – Dimple Panchal Jun 24 at 10:17.

Try this one, I hope this will surely help you. Get-base64-nsstring-from-nsdata.

Unsigned char *buffer = (unsigned char*)malloc(8); buffer0 = d1 bytes ; buffer1 = d2 bytes ; buffer2 = d3 bytes ; buffer3 = d4 bytes ; Not sure what you expect this to do. Bytes return an array, and you are assigning the addresses of the arrays to char elements of your buffer. This buffer won't be filled with any of the data you expect, and the "data" from d2 will partially overwrite those from d1 etc.Also, you shouldn't make much assumptions about the lengths of your byte arrays, especially not if using UTF-16.

In a word: You don't throw the data you expect at your conversion routine. Maybe check that in the debugger.

StrBusiCode = @"64-37-81-d4-39-6d"; NSArray *tmp_arr = strBusiCode componentsSeparatedByString:@"-"; NSMutableData *commandToSend= NSMutableData alloc init; unsigned char whole_byte; char byte_chars3 = {'\0','\0','\0'}; int i; for (i=0; I.

You can use this base64. H and base64. M class to decode to base64 string.

Base64. H #import @interface NSData (Base64) + (NSData *)dataWithBase64EncodedString:(NSString *)string; - (id)initWithBase64EncodedString:(NSString *)string; - (NSString *) base64Encoding; - (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength; @end base64. M #import "base64.

H" static char encodingTable64 = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' }; @implementation NSData (VQBase64) - (id)initWithString:(NSString *)string { if (self = super init) { self initWithBase64EncodedString:string; } return self; } + (NSData *) dataWithBase64EncodedString:(NSString *) string { return NSData allocWithZone:nil initWithBase64EncodedString:string autorelease; } - (id) initWithBase64EncodedString:(NSString *) string { NSMutableData *mutableData = nil; if( string ) { unsigned long ixtext = 0; unsigned long lentext = 0; unsigned char ch = 0; unsigned char inbuf4, outbuf3; short I = 0, ixinbuf = 0; BOOL flignore = NO; BOOL flendtext = NO; NSData *base64Data = nil; const unsigned char *base64Bytes = nil; // Convert the string to ASCII data. Base64Data = string dataUsingEncoding:NSASCIIStringEncoding; base64Bytes = base64Data bytes; mutableData = NSMutableData dataWithCapacity:base64Data length; lentext = base64Data length; while( YES ) { if( ixtext >= lentext ) break; ch = base64Bytesixtext++; flignore = NO; if( ( ch >= 'A' ) && ( ch = 'a' ) && ( ch = '0' ) && ( ch > 4 ); outbuf 1 = ( ( inbuf1 & 0x0F ) > 2 ); outbuf 2 = ( ( inbuf2 & 0x03 ) > 2; outbuf 1 = ((inbuf 0 & 0x03) > 4); outbuf 2 = ((inbuf 1 & 0x0F) > 6); outbuf 3 = inbuf 2 & 0x3F; ctcopy = 4; switch( ctremaining ) { case 1: ctcopy = 2; break; case 2: ctcopy = 3; break; } for( I = 0; I 0 ) { if( charsonline >= lineLength ) { charsonline = 0; result appendString:@"\n"; } } } return NSString stringWithString:result; } @end Please check and let me know if any issue.

If you look at the 2 last numbers you give as example, you will notice conversion match. Because the hi and low parts are the same. Just swap the hi and low words.

And I don't really see the poin about all that code on this page! ;-) – Tristan Leblanc Jul 3 at 11:26 the point... sorry. – Tristan Leblanc Jul 3 at 11:40 Sorry guys, the 'Tripper' badge should exist, at least for me.. Using the OpenSSL is a possible options x2on.De/2010/12/16/… Then you can use the BIO functions to encode or decode 64bits, among other usefull things.. – Tristan Leblanc Jul 5 at 1:20.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions