How do I convert characters (in arrays and strings) to its respective ascii value. I want to do that so I can encrypt some variables for a save file, to prevent tampering(or at least not useful tampering). Thanks.
This is a discussion on converting chars to ascii equivilant within the C++ Programming forums, part of the General Programming Boards category; How do I convert characters (in arrays and strings) to its respective ascii value. I want to do that so ...
How do I convert characters (in arrays and strings) to its respective ascii value. I want to do that so I can encrypt some variables for a save file, to prevent tampering(or at least not useful tampering). Thanks.
how do you think they are stored in memory??
as characters?
remember computers only understand numbers!
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Stoned_Coder is right.
But for knowledge sake, use the stty raw echo command. Get the input and the raw echo will convert it to hex.
This is just a little C that I put together for you...lolCode:#include <stdio.h> #include <stdlib.h> void main(){ char input; system("stty raw -echo"); printf("This program is designed to convert characters into hex" " value\n\r"); printf("Press q at any time to quit this program"); while(input != 'q'){ fflush(stdin); printf("\n\rPlease enter a character:"); scanf("%c", &input); printf("\n\rChahrater entered: %c", input); printf("\n\rHexidecimal value: %x", input); printf("\n\n\rPress q at any time to quit this program"); } printf("\n\r\n\rThank you\n\r"); system("stty -raw echo"); }Just to test that conversion works......printf. Object oriented is pretty much the same way.
But this will not make anything secure!!!
Or you could use itoa
-Govtcheez
govtcheez03@hotmail.com