Solved

Converting  guid as a null-termintated string binary to hex

Posted on 2014-01-09
2
818 Views
Last Modified: 2016-02-29
Hi All,

I have a GUID : 373D06E9-587E-4930-B846-12500FF1AC2F which needs to be converted into hexadecimal using Cocoa or objective C.



Can some one please let me know how to do that.

Thanks,
Ravi
0
Comment
Question by:rkankula
2 Comments
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 500 total points
ID: 39770610
GUID is 128-bit value displayed as 32 hexadecimal digits.
I hope this example will help you:
        NSString *source = @"373D06E9-587E-4930-B846-12500FF1AC2F";
        NSString *line = [source stringByReplacingOccurrencesOfString:@"-" withString:@""];
        NSUInteger length = [line length];
        
        NSUInteger cnt = 0;
        unichar symbols[2];
        while ( cnt < length ) {
            symbols[0] = [line characterAtIndex:cnt];
            symbols[1] = [line characterAtIndex:cnt + 1];
            NSString *one = [NSString stringWithCharacters:symbols length:2];
            
            NSScanner *scanner = [NSScanner scannerWithString:one];
            unsigned hexNum;
            [scanner scanHexInt:&hexNum];
            
            NSLog(@"0x%@ %i", one, hexNum);
            
            cnt += 2;
        }

Open in new window

0
 

Author Closing Comment

by:rkankula
ID: 39771771
Thanks this will be helpful
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Advice on suitable tablet device. 13 113
How can I set a timer to automatically take a picture using the Xamarin MediaPlugin 2 59
iOS and RAM 7 51
tableview is not updating 1 11
The release of the iPhone 6 and the iPhone 6 Plus was extremely successful for Apple. However when iOS 8.1 was introduced, many iPhone users complained of quick battery drainage. Without even knowing, you may be unnecessarily using up your battery p…
In this article we will discuss some EI Capitan Mail app issues and provide some manual process to resolve them.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question