Hash function - Object ID/IP address to 2D co-ordinates
I'm trying to reverse engineer and extend code that I have inherited from another postgrad student (now gone).
Basically he extended a SHA-1 library (see attached) so that an IP address/object id could be converted into a hashed 40 digit hex value (DhtT_Key_Bytes) (and provided a function to easily convert that to an int value). The functions in the library are called as per the below:
I need to change this to still take an IP address or object ID but instead to hash it into (x,y) co-ordinates (within a given area). Can someone please advise me as to how I'd begin to even go about this?
my_addr = ip_support_address_from_node_id_get(my_node_objid);
ip_address_print (str, my_addr);
printf ("\nThe value of my IP address is : %s", str);
InetT_my_addr = inet_address_from_ipv4_address_create (ip_addr_ptr);
val = ip_addr_ptr;
// initialize the SHA-1 Hash context
// allocate room for the SHA-1 Hash
key = (DhtT_Key_Bytes) op_prg_mem_alloc(20);
// update() keeps a "running total" of the SHA-1, but since we're only hashing 32 bits, we //only use it once
sha_update(&context, (unsigned char*)&val, sizeof(int));
// store the final SHA-1 as the DHT ID
intnodeID = sha_get_int_id(key);
Many thanks in advance.