#include<stdio.h> #include <stdlib.h> unsigned int SDBMHash(char *str) { unsigned int hash = 0; while (*str) { // equivalent to: hash = 65599*hash + (*str++); hash = (*str++) + (hash << 6) + (hash << 16) - hash; } return (hash & 0x7FFFFFFF); } //哈希用于SHA256加密 哈希只能加密无法解密 还运用于卡巴斯基病毒库的源码中,应用广,功能<span style="font-family: Arial, Helvetica, sans-serif;">非常强大</span> void main() { printf("%u", SDBMHash("rocket")); printf("\n%u", SDBMHash("rocket")); printf("\n%u", SDBMHash("zrf-rocket")); printf("\n%u",SDBMHash("黑鹰")); getchar(); }
版权声明:本文为博主原创文章,欢迎指出代码不良之处,提出代码优化方案。欢迎指点,黑夜代码,拼命更新,努力奋斗中......
时间: 2024-10-12 13:46:33