Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import c4d
- def hashstr(s):
- hash = 5381
- for x in s:
- hash = (( hash << 5) + hash) + ord(x)
- return hash & 0xFFFFFFFF
- def hashid(text):
- final_id = int(hashstr(text))
- if final_id < 0:
- final_id = -final_id
- return final_id
- def main():
- #correct
- text = "spot_light.samples"
- print "passed string: {}, string id :{}".format(text, hashid(text))
- #incorrect
- text = "spot_light.drop_off"
- print "passed string: {}, string id :{}".format(text, hashid(text))
- #incorrect
- text = "spot_light.dropoff"
- print "passed string: {}, string id :{}".format(text, hashid(text))
- #incorrect
- text = "spot_light.drop.off"
- print "passed string: {}, string id :{}".format(text, hashid(text))
- if __name__=='__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement