mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-05 06:07:58 +08:00
- Code refactoring - Fix a bug that the other player will not become the host of the room at once, when the player disconnect in link play. > Maybe add many unknown bugs. XD > The song database `arcsong.db` will not used in the future. You can use a tool in `tool` folder to import old data.
28 lines
511 B
Python
28 lines
511 B
Python
import hashlib
|
|
import os
|
|
|
|
|
|
def md5(code):
|
|
# md5加密算法
|
|
code = code.encode()
|
|
md5s = hashlib.md5()
|
|
md5s.update(code)
|
|
codes = md5s.hexdigest()
|
|
|
|
return codes
|
|
|
|
|
|
def get_file_md5(file_path):
|
|
# 计算文件MD5
|
|
if not os.path.isfile(file_path):
|
|
return None
|
|
myhash = hashlib.md5()
|
|
with open(file_path, 'rb') as f:
|
|
while True:
|
|
b = f.read(8096)
|
|
if not b:
|
|
break
|
|
myhash.update(b)
|
|
|
|
return myhash.hexdigest()
|