Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 生成url的唯一哈希键_C++_Boost_Hash - Fatal编程技术网

C++ 生成url的唯一哈希键

C++ 生成url的唯一哈希键,c++,boost,hash,C++,Boost,Hash,我想生成url的唯一哈希键。 使用boosthash的atm-im std::size_t seed = 0; boost::hash_combine(seed, host); boost::hash_combine(seed, path); boost::hash_combine(seed, query); boost::hash_combine(seed, fragment); 但散列键通常是重复的…:( 有人有简单的替代方案吗?尝试为C实现一些md5函数我认为代码中

我想生成url的唯一哈希键。 使用boosthash的atm-im

  std::size_t seed = 0;
  boost::hash_combine(seed, host);
  boost::hash_combine(seed, path);
  boost::hash_combine(seed, query); 
  boost::hash_combine(seed, fragment);
但散列键通常是重复的…:(


有人有简单的替代方案吗?

尝试为C实现一些md5函数

我认为代码中没有错误。此虚拟示例的哈希值不同:

#include <boost/functional/hash.hpp>
#include <cstdio>

int main()
{
    size_t seed = 0;
    std::string s1("www.finanzen.de");
    std::string s2("geldanlage-boerse.html");
    std::string s3("geldanlage-china.html");

    boost::hash_combine(seed, s1);
    boost::hash_combine(seed, s2);
    fprintf(stdout, "%016lx\n", seed);

    seed = 0;
    boost::hash_combine(seed, s1);
    boost::hash_combine(seed, s3);
    fprintf(stdout, "%016lx\n", seed);
    return 0;
}

因此,您可能在发布内容中看不到的某个地方出现了转换/溢出问题。

主机、
路径
和其他类型是什么?嗯,问题是我经常会得到9223372036854775807,我将原始密钥放在bigint(20)定义的mysql数据库中.?你能给出一些具体的输入产生这个散列的例子吗?还有,如前所述,你正在散列的变量的类型。(最好是一个简单的例子,按照Mat给出的思路。)嘿,问题是bigint。,现在我使用无符号bigint及其工作方式!THX
#include <boost/functional/hash.hpp>
#include <cstdio>

int main()
{
    size_t seed = 0;
    std::string s1("www.finanzen.de");
    std::string s2("geldanlage-boerse.html");
    std::string s3("geldanlage-china.html");

    boost::hash_combine(seed, s1);
    boost::hash_combine(seed, s2);
    fprintf(stdout, "%016lx\n", seed);

    seed = 0;
    boost::hash_combine(seed, s1);
    boost::hash_combine(seed, s3);
    fprintf(stdout, "%016lx\n", seed);
    return 0;
}
0x7fffffffffffffff