teknoraver

strfry

Jun 14th, 2025 (edited)
1,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #define _GNU_SOURCE
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdint.h>
  5.  
  6. uint32_t djb2(const char *str)
  7. {
  8.     uint32_t hash = 5381;
  9.     int c;
  10.  
  11.     while ((c = *str++))
  12.         hash = hash * 33 + c;
  13.  
  14.     return hash;
  15. }
  16.  
  17. int main(void)
  18. {
  19.     char s[] = "codroipo ";
  20.  
  21.     while (djb2(s) != 0xd07f3c4 && djb2(s) != 0x8f62f044) {
  22.         strfry(s);
  23.         puts(s);
  24.     }
  25.  
  26.     return 0;
  27. }
Advertisement