Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. # coding=utf-8
  2.  
  3. import os
  4. import zlib
  5. import hashlib
  6. import time
  7.  
  8. ##### NOMINATIONS FOR GODNOTA DETECTION #####
  9. aiNominations = [
  10. "ruvn1-win",
  11. "ruvn1-best-art",
  12. "ruvn1-best-script",
  13. "ruvn1-fail"]
  14.  
  15. def md5(fname):
  16. hash_md5 = hashlib.md5()
  17. with open(fname, "rb") as f:
  18. for chunk in iter(lambda: f.read(4096), b""):
  19. hash_md5.update(chunk)
  20. return hash_md5.hexdigest()
  21.  
  22. def detectGodnotaWithSalt(magicDust,contestItems):
  23. md5winarray = sorted(contestItems, key=str.lower, reverse=False)
  24. md5winhash = magicDust.join(md5winarray)
  25. md5wincrc = zlib.crc32(md5winhash)
  26. win_index = md5wincrc%len(contestItems)
  27. win_item = md5winarray[win_index]
  28. return win_item
  29.  
  30. md5map = {}
  31. md5array = []
  32.  
  33. print("Reading novells...")
  34. for file in os.listdir("./"):
  35. if str.lower(file).endswith(".zip") or str.lower(file).endswith(".rar") or str.lower(file).endswith(".exe"):
  36. file_hash = md5("./"+file)
  37. md5map[file_hash] = file
  38. md5array.append(file_hash)
  39. print(file + ": " + file_hash)
  40.  
  41. print("Done! Novells:"+ str(len(md5array)) +". Contest results:")
  42. for index in range(len(aiNominations)):
  43. aiMagicDust = aiNominations[index]
  44. win_md5 = detectGodnotaWithSalt(aiMagicDust,md5array)
  45. print(" Nomination #"+str(index+1)+", "+aiMagicDust+": winner="+md5map[win_md5] + " ("+win_md5+")")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement