Link to home
Start Free TrialLog in
Avatar of garzajd
garzajd

asked on

Need to convert text to hex value... any ideals?

Hello,
 Heres my situation. In my company (like most) there are very few people who can use a computer much less configure one. So in order to make my life easier to setup user I have a program (mainly in C++) that prompts the user for there name and email address.. From there it takes those values and puts them into the registry in the apropriate place to configure Outlook Express. Everything works well. After they do that they open OE and everything is ready to go.. Except one thing it prompts them for there password -- normally this is no problem; however in my never ending quest to make it easy enough for a monkey I am trying to find someway to have my program also prompt for their password and then take that value and enter into the registry in the correct place. Sounds simple - but Outlook Express requires the registry value for the accounts password to be in Hex format. This is where I am stuck. I am looking for a solution or possiably other ideals to simplify this situation. I know simply sending a message telling them how to enter there password and have it save it seems simple enough, but that would create more headaches then needed.
Our client platform is Windows NT 4.0 email client is Outlook Express
Avatar of schwertner
schwertner
Flag of Antarctica image

1. Reading the entered ASCII string sequential you can read  every single entered character. Let us think that you
have read 'A'.
2. Now you have the select the first and the second Hex. number of the presentation of this letter.
In every programming language you can find a character function (POS or ORD or something else) with
a character parameter. It returns the number of the place  in the ASCII table on the given character.I think in C++ you can simple use the character as a digit or somehow to place it in a integer field. Let us suppose you have placed the character in in the field C.
3. To isolate the first hex. digit divide C by 16. So if C is 60 it will return 3
4. To isolate the second hex.digit use MOD function.
60 mod 16 is 12. Try to find MOD function in the library or simply emulate it by subtracting 16 from C.
5. Convert the first and the second number (from 2. and 3.) into hexadecimals. To do this use a table like
Character   Number
0           0
1           1
2           2
...        ...
9           9
a           10
b           11
c           12
d           13
e           14
f           15
You can use 2 arrays (one character, second integer).
 

 

5. Try to figure out if your programming language supports function in the libraries for direct conversion of characters
into hex. digits. This will help you to avoid some of the above steps.

There are also some links to libraries with subroutines doing this like
Try this link

http://www.simtel.net/pub/msdos/binaryed/
Avatar of jonnin
jonnin

c++ supports hex. look up "hex" in the ios reference,
its one of those manipulator things with funny syntax like setprecision etc...

I think they have used some algorithm. I just cannot believe that converting the text string into a hexadecimal numeric string solves the whole....

CJ
I think 500 points is a typo. Please decrease the points.
What language?
Avatar of garzajd

ASKER

Thanks all thus far. 500 points is not a typo I need a solution . My preffered language would be in C, C++
Obviously I'm not very good at the whole programming thing, but I know the basics.
I'll play with what I have so far and see what I can come up with.. thanks
If I understand you correctly you want the Hex representation of a string of ASCII characters to write to the registry. If you don't want to get involved in C++ then the following snippet will illustrate a quick and dirty method of doing the job.

#include    <stdio.h>
#include    <stdlib.h>

int main(int argc, char * argv[])
{
char    sz_ascii[]="12345ABCDE";
char *  ptr;
int     i,j;

     /* Find the length of the input string */
     i=strlen(sz_ascii);
     /* Allocate memory for the output string */
     /* This will be twice the length of the output */
     /* plus 1 character for the trailing null */
     ptr=(char *)malloc((i*2)+1);
     /* Set the entire output string to nulls */
     memset(ptr,(i*2)+1,0x00);
     /* For each input character place the hex */
     /* version in the output string */
     for(j=0;j<i;j++)
         sprintf(ptr+(j*2),"%02X",sz_ascii[j]);
     /* Print the input and out strings to show it worked */
     printf("%s - %s\n",sz_ascii,ptr);
     /* Free up the allocated memory */
     free(ptr);
     return 0;
}

Cheers - Gavin
This person has been suspended for multiple violations of the Member Agreement, and will reject the proposed answer, and return your question to the Active Questions List.  The Moderator Group is deleting all 388 locked questions.

These were posted by three persons:

quirkyquirky
EliteKiller
liloXwin
 
Thank you,
ComTech
CS Admin @ EE

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
ASKER CERTIFIED SOLUTION
Avatar of Jgould
Jgould

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial