|
-
Nov 24th, 2002, 11:04 PM
#1
Thread Starter
New Member
Convert Character String to Hex using C
I'm probably just not thinking tonight because _a_ solution to this is on the tip of my fingers but I can't make it happen. Please keep in mind, I'm sticking mostly to C conventions, trying to include as little C++ as possible (for the sake of some requirements I put on myself early on in the project proposal).
What I'm trying to do is take a string in from a user (scanf()) and convert that string to Hex. I think I need to look at each character sequentially, find the ASCII value for that character, and then convert that ASCII value to hex. As part of my final requirements, I will need to be able to convert to and from Binary as well. Is there a good way to do this in C?
Here's an example:
User Enters: abc
In Binary: 01100001 01100010 01100011
In Hex: 61 62 63
Background: For those that care, I'm implementing SHA-1 very crudely. For my Information Systems Security class, I'm comparing speed differences between an implementation in VB and C. The user will simply be allowed to enter a phrase or some text at a prompt and the application will find the hash for that section. The information I am following for the implementation is from NIST (National Institute of Standards and Technology). The document is FIPS PUB 180-1.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|