Hi,
I was working on a program convert 16-HEXA-character key to be 8-ASCII-character key. apparently I am having problem for testing it because it producces strange symbols it also uses an auxilary program that converts Hex value into decimal.
Can anyone see if the way I am testing the program is correct ?
Code:code int main() { int i; ByteType y; ByteType X [16] = "FFFFFFFFFFFFFFFF"; for( i = 0 ; i < 16; i++) { y = ASCIZ( &X[i]) ; printf("the corresponding characters are %c\n", y); } } ByteType ASCIZ(ByteType *Addr) { int i, v1, v2; ByteType a1, a2, v; /* Convert 16-HEXA-character key to be 8-ASCII-character key. */ for (i = 0; i < 8; i++) { a1 = *Addr++; if (i == 7) a2 = *Addr; else a2 = *Addr++; /* Convert two HEXA characters into their decimal value. */ v1 = Convert(a1); v2 = Convert(a2); /* Convert the two decimal value to be one ASCII character. */ v = ((v1 * 16) + v2); } return v; } /* there is function that converts Hex to decimal */ int Convert(ByteType val ) { if ((val >= 0 ) && (val <= '9' )) return val; else ... }



LinkBack URL
About LinkBacks


