百科问答小站 logo
百科问答小站 font logo



请问这段代码是什么意思,据说能让人月入过w? 第1页

  

user avatar   lu-mi-ya-56 网友的相关建议: 
      

这是DJB2 hash算法,用途将一个字符串映射为一个整数,由Daniel J. Bernstein在1991年发明……

       hash(unsigned char *str) {     unsigned long hash = 5381;     int c;      while (c = *str++)         hash = ((hash << 5) + hash) + c; /* hash * 33 + c */      return hash; }     

介绍可以看这里

Written by Daniel J. Bernstein (also known as djb), this simple hash function dates back to 1991.
Hash functions have wide applications in computer science and in cryptography. They are used to map a potentially large amount of data to a number that represents it.
For example, the hash function from this code snippet maps Hello to 210676686969, but Hello! to 6952330670010. Despite the fact there’s only one character different (the exclamation mark), the number returned is completely different.



  

相关话题

  我在编程时给变量命名总觉得困难,有没有什么实用技巧? 
  ORM 框架能自动防止SQL注入攻击吗? 
  既然在语言层面上 Java 要落后于 C#,那为何国内 Java 架构到处都是? 
  我听说以前的系统没有图形界面,那他们是用 C# 等语言直接敲代码吗? 
  同事离职,我接盘了个垃圾项目,该如何是好? 
  PHP、Java、Python、C、C++ 这几种编程语言都各有什么特点或优点? 
  我怎样成为@vczh一样的大神? 
  编程究竟难在哪? 
  一名大二的计算机专业的学生,目前学了很多编程语言,但都学得很浅。是不是应该专攻一门感兴趣的语言? 
  在C#下有什么好办法可以替代if-else和switch-case? 

前一个讨论
为什么现在的男孩子谈恋爱都喜欢白嫖?
下一个讨论
有律师执照的律师,真的可以随时说出某个人违反了什么法、第几条吗?





© 2025-03-28 - tinynew.org. All Rights Reserved.
© 2025-03-28 - tinynew.org. 保留所有权利