Hash Functions and CRC
CSC-327 · Semester V · Cryptography
#include <stdio.h> #include <string.h> long djb2(char *s) { long h = 5381; for (int i = 0; s[i] != 0; i++) { h = h * 33 + s[i]; } return h; } int main() { string msg; printf("Enter string: "); scanf("%s", &msg); printf("djb2: %lx\n", djb2(msg)); return 0; }
Write some code, then press Run. Stdout and errors appear here.