开发者

Numeric operations over SHA-1 generated keys in C#

开发者 https://www.devze.com 2022-12-30 01:59 出处:网络
I\'m trying to implement a Chord distributed hash table. I want to开发者_JAVA技巧 use SHA-1 as the hash function to generate node ids and map values to the DHT. However, I\'ll need to use numerical op

I'm trying to implement a Chord distributed hash table. I want to开发者_JAVA技巧 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号