Lyndir / Pearl

Library of components and shared code for applications targetted toward the iPhone OS.
https://github.com/Lyndir/Pearl/wiki
Apache License 2.0
44 stars 9 forks source link

base64 decoding error #4

Open wvdhaute opened 10 years ago

wvdhaute commented 10 years ago

Hey Maarten,

Seems to be an error in the base64 decoding algo Try encoding the string "Test description" and decoding it back using your algo vs the ios7 decoding

Thought you should know but I guess since ios7 introduced a native base64 api and opened up a private api for ios versions < 7 yours can go away

    NSString *test = @"Test description";
    NSData *testBytes = [test dataUsingEncoding:NSUTF8StringEncoding];
    NSString *testResult = [testBytes encodeBase64];
    dbg(@"result: %@", testResult);
    NSData *testBytes2 = [testResult decodeBase64];
    NSString *testResult2 = [[NSString alloc] initWithData:testBytes2 encoding:NSUTF8StringEncoding];
    dbg(@"result2: %@", testResult2);
    NSData *testBytes3 = [[NSData alloc] initWithBase64EncodedString:testResult options:0];
    NSString *testResult3 = [[NSString alloc] initWithData:testBytes3 encoding:NSUTF8StringEncoding];
    dbg(@"result3: %@", testResult3);