infogulch

theoretical hash functions

Apr 2nd, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. // Hash functions:
  2. int Hash(byte[] bytes);
  3. int Hash_Add(int hash, byte add);
  4. int Hash_Remove(int hash, byte remove);
  5.  
  6. // With variables:
  7. byte[] x;
  8. byte b;
  9.  
  10. // Where & is binary concat
  11.  
  12. // Such that:
  13. Hash(x & b) == Hash_Add(Hash(x), b)
  14.     // String example:
  15.     Hash("abcd") == Hash_Add(Hash("abc"), "d")  // this is very normal for hash funtions
  16.  
  17. // AND such that:
  18. Hash(x) == Hash_Remove(Hash(b & x), b) // notice the order of b and x
  19.     // String example:
  20.     Hash("bcd") == Hash_Remove(Hash("abcd"), "a")
  21.  
  22. // Also, order is important. I.e.
  23. Hash(x & b) != Hash(b & x)
Advertisement
Add Comment
Please, Sign In to add comment