Advertisement
gr4ph0s

c4dToa paramid

Apr 15th, 2017
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. import c4d
  2.  
  3. def hashstr(s):                                                                                                                                
  4.     hash = 5381
  5.     for x in s:
  6.         hash = (( hash << 5) + hash) + ord(x)
  7.     return hash & 0xFFFFFFFF
  8.  
  9. def hashid(text):
  10.     final_id = int(hashstr(text))
  11.     if final_id < 0:
  12.         final_id = -final_id
  13.        
  14.     return final_id
  15.  
  16. def main():
  17.     #correct
  18.     text = "spot_light.samples"
  19.     print "passed string: {}, string id :{}".format(text, hashid(text))
  20.    
  21.     #incorrect
  22.     text = "spot_light.drop_off"
  23.     print "passed string: {}, string id :{}".format(text, hashid(text))
  24.    
  25.     #incorrect
  26.     text = "spot_light.dropoff"
  27.     print "passed string: {}, string id :{}".format(text, hashid(text))
  28.    
  29.     #incorrect
  30.     text = "spot_light.drop.off"
  31.     print "passed string: {}, string id :{}".format(text, hashid(text))
  32.  
  33. if __name__=='__main__':
  34.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement