找到一个hash函数
来源:互联网 发布:nodejs如何运行js文件 编辑:程序博客网 时间:2024/04/26 13:47
前言
在lua5.3.3代码中看到一个hash函数,摘出来玩玩。
试验
// hw.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <windows.h>#include <stdlib.h>#include <stdio.h>#include <math.h>#include <time.h>unsigned int hashProc(const char* pcSrc, size_t l, unsigned int seed){ unsigned int h = seed ^(unsigned int)l; size_t step = (l >> 5) + 1; for (; l >= step; l -= step) { h ^= ((h << 5) + (h >> 2) + (BYTE)pcSrc[l - 1]); } return h;}int main(int argc, char* argv[]){ srand((UINT)time(NULL)); const char* pcMsg = "string for calc hash"; UINT iHash = hashProc(pcMsg, strlen(pcMsg), rand()); printf("hash value = 0x%X, str = [%s]\r\n", iHash, pcMsg); system("pause"); /** run result hash value = 0xEE996D0, str = [string for calc hash] 请按任意键继续. . . */ return 0;}
0 0
- 找到一个hash函数
- 一个很好的HASH函数
- 一个非常好的字符串Hash函数
- Hash 函数、Hash表
- hash函数
- hash函数
- hash函数
- hash函数
- Hash函数
- Hash函数
- Hash函数
- hash函数
- hash函数
- Hash函数
- hash函数
- Hash函数
- hash函数
- Hash函数
- 安装express
- Log:解决IllegalStateException: Can not perform this action after onSaveInstanceState
- BZOJ 1026: [SCOI2009]windy数 (裸的数位dp)
- __BEGIN_DECLS 和 __END_DECLS 的理解
- 优化代码的几个技巧
- 找到一个hash函数
- Swift 中的SDWebImage类似库Kingfisher
- TextView支持的HTML标签及其他
- maven构建MyBatis项目
- Android Studio Gradle编译报input jar file is specified twice
- springMVC+easyUI实现combobox动态级联查询
- ios高德地图流程
- Hibernate、JPA 映射字段问题[ImprovedNamingStrategy]
- SeaJS与RequireJS最大的区别