aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/ipm/utils/freeze.py6
-rw-r--r--src/ipm/utils/hash.py6
2 files changed, 6 insertions, 6 deletions
diff --git a/src/ipm/utils/freeze.py b/src/ipm/utils/freeze.py
index f03078f..8f7698f 100644
--- a/src/ipm/utils/freeze.py
+++ b/src/ipm/utils/freeze.py
@@ -2,7 +2,7 @@ from pathlib import Path
from . import _freeze
from ..exceptions import FileNotFoundError, VerifyFailed
from ..models.ipk import InfiniPackage, InfiniFrozenPackage
-from .hash import hash_ifp, verify_ifp
+from .hash import ifp_hash, ifp_verify
from ..typing import StrPath
import tempfile
@@ -31,7 +31,7 @@ def build_ipk(ipk: InfiniPackage) -> InfiniFrozenPackage:
str(ifp_path),
)
- (dist_path / ipk.hash_name).write_bytes(hash_ifp(ifp_path))
+ (dist_path / ipk.hash_name).write_bytes(ifp_hash(ifp_path))
return InfiniFrozenPackage(source_path=ifp_path, **{"name": ipk.name})
@@ -44,7 +44,7 @@ def extract_ipk(source_path: StrPath, dist_path: str | Path) -> InfiniPackage:
if not hash_path.exists():
raise VerifyFailed("哈希文件不存在!")
- if not verify_ifp(ifp_path, hash_path.read_bytes()):
+ if not ifp_verify(ifp_path, hash_path.read_bytes()):
raise VerifyFailed("文件完整性验证失败!")
temp_dir = tempfile.TemporaryDirectory()
diff --git a/src/ipm/utils/hash.py b/src/ipm/utils/hash.py
index 54d5b13..c1fa37b 100644
--- a/src/ipm/utils/hash.py
+++ b/src/ipm/utils/hash.py
@@ -2,7 +2,7 @@ from pathlib import Path
import hashlib
-def hash_ifp(lfp_path: str | Path, block_size=65536) -> bytes:
+def ifp_hash(lfp_path: str | Path, block_size=65536) -> bytes:
sha256 = hashlib.sha256()
with Path(lfp_path).resolve().open("rb") as file:
for block in iter(lambda: file.read(block_size), b""):
@@ -10,6 +10,6 @@ def hash_ifp(lfp_path: str | Path, block_size=65536) -> bytes:
return sha256.digest()
-def verify_ifp(lfp_path, expected_hash) -> bool:
- actual_hash = hash_ifp(lfp_path)
+def ifp_verify(lfp_path, expected_hash) -> bool:
+ actual_hash = ifp_hash(lfp_path)
return actual_hash == expected_hash