我使用的是djb2哈希函数的标准char *版本:
RewriteEngine On
RewriteRule ^(application) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
如何编辑此哈希函数以接受String对象而不是unsigned char *?
答案 0 :(得分:0)
请改用字符串?
unsigned long DJB2(std::string str){
unsigned long hash = 5381;
int c;
for (int i = 0; i < str.length(); ++i) {
c = (int) str[i];
hash = ((hash << 5) + hash) + c;
}
return hash;
}