// types.h /* Written by Huang,Jessica C : jessica9@MIT.EDU Huang,Kai : kaih@MIT.EDU Huang, Edward : eych@MIT.EDU Shi,Melissa F : mshi@MIT.EDU September 25, 2001 May be freely reproduced for educational or personal use */ #ifndef __TYPES_H__ #define __TYPES_H__ #include typedef unsigned char Byte; // 8 bits typedef unsigned short Word; // 16 bits typedef Word Vect[ 2 ]; // array of 2 Words typedef Byte Key[ 8 ]; // array of 8 Bytes // converts a Vect into an unsigned long unsigned long convertVect( Vect vect ) { unsigned long n = 0; n = vect[ 0 ]; n = n << 16; n = n + vect[ 1 ]; return n; } // copies "from" into "to" void copyVect( Vect to, Vect from ) { to[ 0 ] = from[ 0 ]; to[ 1 ] = from[ 1 ]; } // copies "from" into "to" void copyKey( Key to, Key from ) { int i; for ( i = 0; i < 8; ++i ) to[ i ] = from[ i ]; } // prints the value of "key" in hex void printKeyHex( Key key ) { int i; for ( i = 0; i < 8; ++i ) printf( "%x", key[ i ] ); } // prints the value of "key" as characters void printKeyChar( Key key ) { int i; for ( i = 0; i < 8; ++i ) printf( "%c", (char) key[ i ] ); } #endif //__TYPES_H__