4

DJB2 Hash in Python

 2 years ago
source link: https://gist.github.com/amakukha/7854a3e910cb5866b53bf4b2af1af968
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

metala commented on Nov 5, 2021

edited

You don't need itertools.chain, since you have optional initial value in functools.reduce.

djb2 = lambda x: functools.reduce(lambda x,c: (x*33 + ord(c)) & 0xFFFFFFFF, x, 5381)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK