C++ Builder快速响应的测试套件,用于分析C ++哈希函数

 
 

快速响应测试套件以分析哈希函数

没有通用哈希的良好哈希函数。取决于上下文,不同的标准确定哈希的质量。要使用从您希望使用相同分布的数据中获取的数据来测试您的哈希函数。当查看64位long上的哈希函数时,如果从所有可能的long值中统一提取输入值,则默认哈希函数非常出色。

有多种方法可以测试非加密哈希函数的分布,冲突和性能属性。当涉及哈希冲突或分布时,概率不是一个好主意。为此,一些库利用线性密码分析或其他方法。

SMHasher是一个测试套件,旨在测试非加密哈希函数的分布,冲突和性能属性。它的目标是成为哈希测试的DieHarder,汉武帝药枕并很好地发现了几种流行的哈希值中的缺陷。

template < typename hashtype >
void test ( hashfunc<hashtype> hash, HashInfo * info )
{
  const int hashbits = sizeof(hashtype) * 8;

  printf("-------------------------------------------------------------------------------n");
  printf("--- Testing %s (%s)nn",info->name,info->desc);

  //-----------------------------------------------------------------------------
  // Sanity tests

  if(g_testSanity || g_testAll)
  {
    printf("[[[ Sanity Tests ]]]nn");

    VerificationTest(hash,hashbits,info->verification,true);
    SanityTest(hash,hashbits);
    AppendedZeroesTest(hash,hashbits);
    printf("n");
  }

  //-----------------------------------------------------------------------------
  // Speed tests

  if(g_testSpeed || g_testAll)
  {
    printf("[[[ Speed Tests ]]]nn");

    BulkSpeedTest(info->hash,info->verification);
    printf("n");

    for(int i = 1; i < 32; i++)
    {
      double cycles;

      TinySpeedTest(hashfunc<hashtype>(info->hash),sizeof(hashtype),i,info->verification,true,cycles);
    }

    printf("n");
  }

  //-----------------------------------------------------------------------------
  // Differential tests

  if(g_testDiff || g_testAll)
  {
    printf("[[[ Differential Tests ]]]nn");

    bool result = true;
    bool dumpCollisions = false;

    result &= DiffTest< Blob<64>,  hashtype >(hash,5,1000,dumpCollisions);
    result &= DiffTest< Blob<128>, hashtype >(hash,4,1000,dumpCollisions);
    result &= DiffTest< Blob<256>, hashtype >(hash,3,1000,dumpCollisions);

    if(!result) printf("*********FAIL*********n");
    printf("n");
  }

  //-----------------------------------------------------------------------------
  // Differential-distribution tests

  if(g_testDiffDist /*|| g_testAll*/)
  {
    printf("[[[ Differential Distribution Tests ]]]nn");

    bool result = true;

    result &= DiffDistTest2<uint64_t,hashtype>(hash);

    printf("n");
  }

 

请确保直接在GetIt门户上查看SMHasher测试套件,并在IDE中下载它!

embarcadero-c-builder-smhasher-hashing-6303392


使用RAD Studio,Delphi或C ++ Builder减少开发时间并更快地推向市场。设计。编码。编译。部署。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值