Advertisement
Narzew

NARZEW HASHING ALGORITHM

Oct 24th, 2012
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.12 KB | None | 0 0
  1. #===========================================================================
  2. #**Narzew Hashing Algorithm
  3. #**Narzew
  4. #**Version 1.0
  5. #**24.10.12
  6. #===========================================================================
  7. #**Algorithm to hashing int in one way :)
  8. #===========================================================================
  9. #**NarzewHash.hash_value(value,key) -> hashs value (level 1) with key
  10. #**NarzewHash.super_hash(value, key) -> superhashs value (level 2) with key
  11. #===========================================================================
  12. #**Use free, but give credit to original author
  13. #**Modify free, but give credit to original author
  14. #**Share free, but give credit to original author
  15. #===========================================================================
  16.  
  17. #===========================================================================
  18. #**Moduł NarzewHash
  19. #===========================================================================
  20.  
  21. module NarzewHash
  22.  
  23.     #===========================================================================
  24.     #**hash_value(value,key)
  25.     #===========================================================================
  26.  
  27.     def self.hash_value(x,k=77)
  28.         srand(((300+x*2+k)/2))
  29.         return ((x + rand(x*2) / 2) + 1).to_i
  30.     end
  31.    
  32.     #===========================================================================
  33.     #**super_hash(value, key)
  34.     #**Require : hash_value
  35.      #===========================================================================
  36.    
  37.     def self.super_hash(x,k=91)
  38.         return (((NarzewHash.hash_value(NarzewHash.hash_value(NarzewHash.hash_value(NarzewHash.hash_value(NarzewHash.hash_value(NarzewHash.hash_value(NarzewHash.hash_value(x+1,(k-3))+113,(k+3))+294,(k*7))+371,(x-13))+4,(x-7))+152,(k-31))+1,(k*3))+317)/113+1)*7)
  39.     end
  40.    
  41.     #===========================================================================
  42.     #**End of module
  43.     #===========================================================================
  44.    
  45. end
  46.  
  47. #===========================================================================
  48. #**End of script
  49. #===========================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement