pesc.c
uint32_t HexToUInt32(char* str, int start)
{
	uint32_t v = 0;
	for (size_t i = 0; i < 8; i++)
	{
		char tmp = str[start + i];
		#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
			if      (tmp >= 'A' && tmp <= 'F') v += (tmp - 'A' + 0xA) << ((7 - i) * 4);
			else if (tmp >= 'a' && tmp <= 'f') v += (tmp - 'a' + 0xA) << ((7 - i) * 4);
			else if (tmp >= '0' && tmp <= '9') v += (tmp - '0')       << ((7 - i) * 4);
		#else
			if      (tmp >= 'A' && tmp <= 'F') v += (tmp - 'A' + 0xA) << (i * 4);
			else if (tmp >= 'a' && tmp <= 'f') v += (tmp - 'a' + 0xA) << (i * 4);
			else if (tmp >= '0' && tmp <= '9') v += (tmp - '0')       << (i * 4);
		#endif
		else
		{
			fputs("Unsupported character in key\n", stderr);
			exit(EXIT_FAILURE);
		}
	}
	return v;
}
// Convert 8 hex chars from string to uint32
Convert 8 hex chars from string to uint32
Convert 8 hex chars from string to uint32
uint32_t HexToUInt32(char* str, int start)
{
	uint32_t v = 0;
	for (size_t i = 0; i < 8; i++)
	{
		char tmp = str[start + i];
		#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
			if      (tmp >= 'A' && tmp <= 'F') v += (tmp - 'A' + 0xA) << ((7 - i) * 4);
			else if (tmp >= 'a' && tmp <= 'f') v += (tmp - 'a' + 0xA) << ((7 - i) * 4);
			else if (tmp >= '0' && tmp <= '9') v += (tmp - '0')       << ((7 - i) * 4);
		#else
			if      (tmp >= 'A' && tmp <= 'F') v += (tmp - 'A' + 0xA) << (i * 4);
			else if (tmp >= 'a' && tmp <= 'f') v += (tmp - 'a' + 0xA) << (i * 4);
			else if (tmp >= '0' && tmp <= '9') v += (tmp - '0')       << (i * 4);
		#endif
		else
		{
			fputs("Unsupported character in key\n", stderr);
			exit(EXIT_FAILURE);
		}
	}
	return v;
}
uint32_t HexToUInt32 ( char * str , int start ) { uint32_t v = 0 ; for ( size_t i = 0 ; i < 8 ; i ++ ) { char tmp = str [ start + i ] ; #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ if ( tmp >= ' ' && tmp <= ' ' ) v += ( tmp - ' ' + 0xA ) << ( ( 7 - i ) * 4 ) ; else if ( tmp >= ' ' && tmp <= ' ' ) v += ( tmp - ' ' + 0xA ) << ( ( 7 - i ) * 4 ) ; else if ( tmp >= ' ' && tmp <= ' ' ) v += ( tmp - ' ' ) << ( ( 7 - i ) * 4 ) ; #else if ( tmp >= ' ' && tmp <= ' ' ) v += ( tmp - ' ' + 0xA ) << ( i * 4 ) ; else if ( tmp >= ' ' && tmp <= ' ' ) v += ( tmp - ' ' + 0xA ) << ( i * 4 ) ; else if ( tmp >= ' ' && tmp <= ' ' ) v += ( tmp - ' ' ) << ( i * 4 ) ; #endif else { fputs ( " \n " , stderr ) ; exit ( EXIT_FAILURE ) ; } } return v ; }
Convert 8 hex chars from string to uint32
Convert 8 hex chars from string to uint32