'How can I convert NSData to NSString without encoding to base64?

I'm working on a game in Unity and I currently need to authenticate a apple user and receive some data, which apparently can only be done in native code. I found this code online, which works well, but some of the data is encoded in base64 and I need it decoded. I can try and decode it on the Unity side but it doesn't seem to work and it would be better to receive the raw data so I can work with it as I need. The code is below:

[localPlayer fetchItemsForIdentityVerificationSignature:
        ^(NSURL *publicKeyUrl, NSData *signature, NSData *salt, uint64_t timestamp, NSError *error)
        {
            if (error)
            {
                NSLog(@"ERROR: %@", error);
                OnFailed([[error localizedDescription] UTF8String]);
            }
            else
            {
                NSString *signatureb64 = [signature base64EncodedStringWithOptions:0];
                NSString *saltb64 = [salt base64EncodedStringWithOptions:0];
                NSString *playerId = localPlayer.playerID;
                NSString *alias = localPlayer.alias;
                NSString *bundleId = [[NSBundle mainBundle] bundleIdentifier];
     
                OnSucceeded(
                    [[publicKeyUrl absoluteString] UTF8String],
                    timestamp,
                    [signatureb64 UTF8String],
                    [saltb64 UTF8String],
                    [playerId UTF8String],
                    [alias UTF8String],
                    [bundleId UTF8String]
                );
            }
        }
     ];

The data I need decoded is the salt and the signature

If I'm not wrong, what I actually need is to convert from NSData to const char * as it is how the data is returned in the callback, instead of NSData to NSString as I wrote in the title, but I thought the title would sound better like that.

I believe what I need is relatively simple but most of my knowledge is in C# for Unity and some web stuff, so I'm a complete potato regarding cpp and apple in native code. Multiple solutions I found online either didn't compile or returned null.

Thanks in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source