Solved

Converting  guid as a null-termintated string binary to hex

Posted on 2014-01-09
2
829 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Restore MAC  computer back to its original OS 3 57
Rebuilding iPads to accomodate iOS 10 6 35
Inventory management and network map for MACOS 6 57
Google Maps 6 40
     Intro      In this article, I will show you how to parse a JSON in Swift using an open source library called SwiftyJSON (https://github.com/SwiftyJSON/SwiftyJSON). If you haven't heard of a JSON before, it stands for JavaScript Object Notation…
There is a security feature on iOS devices that is nearly impenetrable when it has been activated.  This article will provide some possible solutions as well as necessary steps to take to ensure you do not end up with a locked device.
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.

749 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