Algorithm RS哈希程序
谁能告诉我RS字符串哈希算法的工作原理或算法?我需要它,但在谷歌上找不到。请至少帮助我使用这个算法,我会自己实现它。你的意思是指的字符串哈希算法吗Algorithm RS哈希程序,algorithm,hash,Algorithm,Hash,谁能告诉我RS字符串哈希算法的工作原理或算法?我需要它,但在谷歌上找不到。请至少帮助我使用这个算法,我会自己实现它。你的意思是指的字符串哈希算法吗 uint a = 63689, uint b = 378551 foreach ( byte x ; bytes ) { value = value * a + x; a *= b; } return value; (引自)。Python实现如下: def RSHash(key): a = 63689 b = 378
uint a = 63689, uint b = 378551
foreach ( byte x ; bytes ) {
value = value * a + x;
a *= b;
}
return value;
(引自)。Python实现如下:
def RSHash(key):
a = 63689
b = 378551
hash = 0
for i in range(len(key)):
hash = hash * a + ord(key[i])
a = a * b
return hash
unsigned int RSHash(const std::string& str)
{
unsigned int b = 378551;
unsigned int a = 63689;
unsigned int hash = 0;
for(std::size_t i = 0; i < str.length(); i++)
{
hash = hash * a + str[i];
a = a * b;
}
return hash;
}
/* End Of RS Hash Function */
C++实现如下:
def RSHash(key):
a = 63689
b = 378551
hash = 0
for i in range(len(key)):
hash = hash * a + ord(key[i])
a = a * b
return hash
unsigned int RSHash(const std::string& str)
{
unsigned int b = 378551;
unsigned int a = 63689;
unsigned int hash = 0;
for(std::size_t i = 0; i < str.length(); i++)
{
hash = hash * a + str[i];
a = a * b;
}
return hash;
}
/* End Of RS Hash Function */
无符号整数RSHash(const std::string&str)
{
无符号整数b=378551;
无符号整数a=63689;
无符号整数散列=0;
对于(std::size_t i=0;i
您能告诉我这段代码是用哪种语言编写的吗?它是D格式的(至少根据原始网站)。希望复制到您选择的语言是非常简单的。pallas链接已断开。有什么办法可以更新吗?谢谢这种散列也适用于整数向量吗?“散列”不会被截断为32位。这段代码返回一个非常长的散列。