tags:

views:

34

answers:

1

I'm trying to implement a Chord distributed hash table. I want to use SHA-1 as the hash function to generate node ids and map values to the DHT. However, I'll need to use numerical operations on the SHA-1 generated key, such as a modulo, for example. I wonder in which type of variable should I put the array of bytes I get, and how can I convert from one to another.

A: 

If your key has the maximum length of 8 bytes you can create a long variable from the byte you get. If your output is longer you have to look out for a big-number library for c# which works on byte arrays.

EDIT:

NOTE That .NET Framwork Version 4 has the BigInteger type which just would fit your needs.

There also lots of projects on the internet which also provides similar functionality.

codymanix