x
Solved

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

Posted on 2002-04-23
Medium Priority
337 Views
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
0
Question by:garzajd

LVL 48

Expert Comment

ID: 6965137
1. Reading the entered ASCII string sequential you can read  every single entered character. Let us think that you
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

http://www.simtel.net/pub/msdos/binaryed/
0

LVL 2

Expert Comment

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

0

LVL 22

Expert Comment

ID: 6965618
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
0

LVL 48

Expert Comment

ID: 6968806
I think 500 points is a typo. Please decrease the points.
0

LVL 6

Expert Comment

ID: 6969870
What language?
0

LVL 1

Author Comment

ID: 6969918
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
0

LVL 4

Expert Comment

ID: 6970161
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
0

Expert Comment

ID: 7299409
0

Expert Comment

ID: 7300663
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
0

LVL 54

Expert Comment

ID: 7515048

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
next seven days.

Nic;o)
0

Accepted Solution

Jgould earned 0 total points
ID: 7548117
Question has been closed as per recommendation

JGould-EE Moderator
0

## Featured Post

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.