utils.py 270 B

1234567891011
  1. import random
  2. def random_hash():
  3. return ("%032x" % random.getrandbits(128))[:10]
  4. def ip_from_decimal(dec):
  5. return ".".join([str(int(b, 2)) for b in b_octets(bin(dec)[2:])])
  6. def b_octets(l):
  7. l = l.zfill(32)
  8. return [l[0:8], l[8:16], l[16:24], l[24:32]]