vocaloid-integrity-check 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 vocaloid-integrity-check contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.4
2
+ Name: vocaloid-integrity-check
3
+ Version: 1.0.0
4
+ Summary: Check the integrity of a Vocaloid voicebank by verifying the name digest in its .ddi index
5
+ Author: vocaloid-integrity-check contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Vsynth-Tools/vocaloid-integrity-check
8
+ Project-URL: Issues, https://github.com/Vsynth-Tools/vocaloid-integrity-check/issues
9
+ Keywords: vocaloid,voicebank,ddi,ddb,integrity,md5
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: End Users/Desktop
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Topic :: Multimedia :: Sound/Audio
18
+ Classifier: Topic :: Security
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # vocaloid-integrity-check
25
+
26
+ Check a Vocaloid voicebank when you’re concerned that it may be corrupted or was renamed.
27
+
28
+ Standard library only. Python 3.10+.
29
+
30
+ ## Install
31
+
32
+ ```console
33
+ $ pip install vocaloid-integrity-check
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ```console
39
+ $ vocaloid-integrity-check Yuki.ddi --ddb Yuki.ddb
40
+ hash verified
41
+ name : Yuki (root ARR4)
42
+ stored : 92942a5a960cdf938b3d742d8a75f5df
43
+ expect : 92942a5a960cdf938b3d742d8a75f5df
44
+ ```
45
+
46
+ `--json` prints machine-readable output. If `--ddb` is omitted, the `.ddi` filename is used.
47
+
48
+ ## Results
49
+
50
+ - `hash verified` — the check succeeded.
51
+ - `hash fail` — the check found a mismatch.
52
+ - `hash present, not checkable` — a value is present, but cannot be judged from the files alone (Vocaloid 3/4).
53
+ - `hash not present` — no value was found.
54
+ - `hash not verifiable` — the name cannot be checked in the current environment.
55
+
56
+ Exit status: `0` verified, `1` fail, `2` inconclusive or invalid input.
57
+
58
+ Vocaloid 2 banks are checked. Vocaloid 3/4 banks are recognized, but reported as not checkable rather than verified or failed.
59
+
60
+ ## Notes
61
+
62
+ This is an integrity check, not an authenticity check. `unity-chan_for_Unity` is a known exception; treat a mismatch for it as unknown.
63
+
64
+ ## License
65
+
66
+ MIT.
@@ -0,0 +1,43 @@
1
+ # vocaloid-integrity-check
2
+
3
+ Check a Vocaloid voicebank when you’re concerned that it may be corrupted or was renamed.
4
+
5
+ Standard library only. Python 3.10+.
6
+
7
+ ## Install
8
+
9
+ ```console
10
+ $ pip install vocaloid-integrity-check
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```console
16
+ $ vocaloid-integrity-check Yuki.ddi --ddb Yuki.ddb
17
+ hash verified
18
+ name : Yuki (root ARR4)
19
+ stored : 92942a5a960cdf938b3d742d8a75f5df
20
+ expect : 92942a5a960cdf938b3d742d8a75f5df
21
+ ```
22
+
23
+ `--json` prints machine-readable output. If `--ddb` is omitted, the `.ddi` filename is used.
24
+
25
+ ## Results
26
+
27
+ - `hash verified` — the check succeeded.
28
+ - `hash fail` — the check found a mismatch.
29
+ - `hash present, not checkable` — a value is present, but cannot be judged from the files alone (Vocaloid 3/4).
30
+ - `hash not present` — no value was found.
31
+ - `hash not verifiable` — the name cannot be checked in the current environment.
32
+
33
+ Exit status: `0` verified, `1` fail, `2` inconclusive or invalid input.
34
+
35
+ Vocaloid 2 banks are checked. Vocaloid 3/4 banks are recognized, but reported as not checkable rather than verified or failed.
36
+
37
+ ## Notes
38
+
39
+ This is an integrity check, not an authenticity check. `unity-chan_for_Unity` is a known exception; treat a mismatch for it as unknown.
40
+
41
+ ## License
42
+
43
+ MIT.
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "vocaloid-integrity-check"
7
+ version = "1.0.0"
8
+ description = "Check the integrity of a Vocaloid voicebank by verifying the name digest in its .ddi index"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "vocaloid-integrity-check contributors" }]
13
+ keywords = ["vocaloid", "voicebank", "ddi", "ddb", "integrity", "md5"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Environment :: Console",
17
+ "Intended Audience :: End Users/Desktop",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Topic :: Multimedia :: Sound/Audio",
23
+ "Topic :: Security",
24
+ ]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/Vsynth-Tools/vocaloid-integrity-check"
28
+ Issues = "https://github.com/Vsynth-Tools/vocaloid-integrity-check/issues"
29
+
30
+ [project.scripts]
31
+ vocaloid-integrity-check = "vocaloid_integrity_check.cli:main"
32
+
33
+ [tool.setuptools]
34
+ package-dir = { "" = "src" }
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,42 @@
1
+ """Vocaloid integrity checker.
2
+
3
+ Locates and, where the scheme is known, verifies the name digest stored in a
4
+ Vocaloid voicebank index (``.ddi``).
5
+ """
6
+
7
+ from .checker import (
8
+ ABSENT,
9
+ BLOCK_LEN,
10
+ DIGEST_LEN,
11
+ FAIL,
12
+ PHDC_OFFSET,
13
+ SALTS,
14
+ UNCHECKED,
15
+ UNVERIFIABLE,
16
+ V3V4_PHDC_OFFSET,
17
+ VERIFIED,
18
+ check,
19
+ expected_digest,
20
+ locate_phdc,
21
+ read_digest,
22
+ )
23
+
24
+ __version__ = "1.0.0"
25
+
26
+ __all__ = [
27
+ "check",
28
+ "expected_digest",
29
+ "locate_phdc",
30
+ "read_digest",
31
+ "SALTS",
32
+ "PHDC_OFFSET",
33
+ "V3V4_PHDC_OFFSET",
34
+ "BLOCK_LEN",
35
+ "DIGEST_LEN",
36
+ "VERIFIED",
37
+ "FAIL",
38
+ "ABSENT",
39
+ "UNVERIFIABLE",
40
+ "UNCHECKED",
41
+ "__version__",
42
+ ]
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())
@@ -0,0 +1,124 @@
1
+ """Core integrity check for Vocaloid voicebank indexes (``.ddi``)."""
2
+
3
+ import hashlib
4
+ import re
5
+ import struct
6
+
7
+ # Vocaloid 2 root tag -> (salt prefix, salt suffix) for the name digest.
8
+ SALTS = {
9
+ b"ARR2": ("K2ho", "nF"),
10
+ b"ARR3": ("K2ho", "nF"),
11
+ b"ARR4": ("1m5Pj", "qFE"),
12
+ }
13
+
14
+ V3V4_ROOTS = {b"DBSe"} # retail V3/V4 library
15
+ DEV_ROOTS = {b"DBS "} # development tree, deliberately unsupported
16
+
17
+ PHDC_OFFSET = 0x18 # pos(8) + tag(4) + size(4) + flags(8)
18
+ V3V4_PHDC_OFFSET = 0x1C # as above plus a u32 version after the flags
19
+ DIGEST_LEN = 32
20
+ BLOCK_LEN = 260
21
+
22
+ VERIFIED = "hash verified"
23
+ FAIL = "hash fail"
24
+ ABSENT = "hash not present"
25
+ UNVERIFIABLE = "hash not verifiable"
26
+ UNCHECKED = "hash present, not checkable"
27
+
28
+
29
+ def expected_digest(stem, root):
30
+ """Return the expected digest for *stem* under *root*, or None if unknown."""
31
+ salts = SALTS.get(root)
32
+ if salts is None or not stem.isascii():
33
+ return None
34
+ return hashlib.md5(
35
+ (salts[0] + stem.upper() + salts[1]).encode("ascii")
36
+ ).hexdigest()
37
+
38
+
39
+ def locate_phdc(data, offset=PHDC_OFFSET):
40
+ """Return (offset, size) of the PHDC chunk, or raise ValueError."""
41
+ if len(data) < offset + 8:
42
+ raise ValueError("file too short to contain a voicebank index")
43
+ if data[offset:offset + 4] != b"PHDC":
44
+ raise ValueError(
45
+ f"no PHDC chunk at {hex(offset)}; not a Vocaloid voicebank index"
46
+ )
47
+ size = struct.unpack("<I", data[offset + 4:offset + 8])[0]
48
+ if size < 12 or offset + size > len(data):
49
+ raise ValueError("PHDC size is invalid or runs past end of file")
50
+ return offset, size
51
+
52
+
53
+ def read_digest(data):
54
+ """Return (root, stored digest or None, status note)."""
55
+ root = data[8:12]
56
+
57
+ if root in DEV_ROOTS:
58
+ return root, None, "development tree; not supported"
59
+ if root in V3V4_ROOTS:
60
+ off, size = locate_phdc(data, V3V4_PHDC_OFFSET)
61
+ block = data[off + size:off + size + BLOCK_LEN]
62
+ if len(block) < BLOCK_LEN:
63
+ return root, None, "Vocaloid 3/4 hash store is truncated"
64
+ return root, block[:DIGEST_LEN].decode("ascii", "replace"), ""
65
+
66
+ off, size = locate_phdc(data)
67
+ if root not in SALTS:
68
+ return root, None, "root has no digest block"
69
+ block = data[off + size:off + size + BLOCK_LEN]
70
+ if len(block) < BLOCK_LEN:
71
+ return root, None, "digest block truncated"
72
+ stored = block[:DIGEST_LEN]
73
+ if not re.fullmatch(rb"[0-9a-f]{32}", stored):
74
+ return root, None, "digest block is not lowercase hex"
75
+ return root, stored.decode("ascii"), ""
76
+
77
+
78
+ def check(data, stem):
79
+ """Check *data* against the bank name *stem* and return a result dict."""
80
+ root, stored, note = read_digest(data)
81
+ root_name = root.decode("ascii", "replace")
82
+
83
+ if stored is None:
84
+ return {
85
+ "status": ABSENT,
86
+ "root": root_name,
87
+ "stem": stem,
88
+ "note": note,
89
+ "exit_code": 2,
90
+ }
91
+
92
+ # Vocaloid 3/4: the store is present and readable, but it is derived from the
93
+ # licence volume and the voice name, neither of which is recoverable from the
94
+ # index. Report the value; do not judge it.
95
+ if root in V3V4_ROOTS:
96
+ return {
97
+ "status": UNCHECKED,
98
+ "root": root_name,
99
+ "stem": stem,
100
+ "stored": stored,
101
+ "note": "Vocaloid 3/4 store is licence-derived; value reported, not judged",
102
+ "exit_code": 2,
103
+ }
104
+
105
+ computed = expected_digest(stem, root)
106
+ if computed is None:
107
+ return {
108
+ "status": UNVERIFIABLE,
109
+ "root": root_name,
110
+ "stem": stem,
111
+ "stored": stored,
112
+ "note": "non-ASCII name: expected digest depends on engine locale",
113
+ "exit_code": 2,
114
+ }
115
+ ok = computed == stored
116
+ return {
117
+ "status": VERIFIED if ok else FAIL,
118
+ "root": root_name,
119
+ "stem": stem,
120
+ "stored": stored,
121
+ "computed": computed,
122
+ "note": "" if ok else "digest does not match this name",
123
+ "exit_code": 0 if ok else 1,
124
+ }
@@ -0,0 +1,44 @@
1
+ """Command-line interface for the Vocaloid integrity checker."""
2
+
3
+ import argparse
4
+ import json
5
+ import ntpath
6
+ import sys
7
+
8
+ from .checker import check
9
+
10
+
11
+ def main(argv=None):
12
+ parser = argparse.ArgumentParser(
13
+ prog="vocaloid-integrity-check",
14
+ description="Vocaloid integrity checker. Checks the integrity of a Vocaloid voicebank.",
15
+ )
16
+ parser.add_argument("ddi", help="path to the .ddi file")
17
+ parser.add_argument("--ddb", help="the .ddb filename or path in the same voicebank")
18
+ parser.add_argument("--json", action="store_true", help="output JSON")
19
+ args = parser.parse_args(argv)
20
+
21
+ stem = ntpath.splitext(ntpath.basename(args.ddb or args.ddi))[0]
22
+ try:
23
+ with open(args.ddi, "rb") as fh:
24
+ result = check(fh.read(), stem)
25
+ except (OSError, ValueError) as exc:
26
+ print(f"error: {exc}", file=sys.stderr)
27
+ return 2
28
+
29
+ if args.json:
30
+ print(json.dumps(result, indent=2))
31
+ else:
32
+ print(result["status"])
33
+ if result.get("stored"):
34
+ print(f' name : {result["stem"]} (root {result["root"]})')
35
+ print(f' stored : {result["stored"]}')
36
+ if result.get("computed"):
37
+ print(f' expect : {result["computed"]}')
38
+ if result.get("note"):
39
+ print(f' note : {result["note"]}')
40
+ return result["exit_code"]
41
+
42
+
43
+ if __name__ == "__main__":
44
+ sys.exit(main())
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.4
2
+ Name: vocaloid-integrity-check
3
+ Version: 1.0.0
4
+ Summary: Check the integrity of a Vocaloid voicebank by verifying the name digest in its .ddi index
5
+ Author: vocaloid-integrity-check contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Vsynth-Tools/vocaloid-integrity-check
8
+ Project-URL: Issues, https://github.com/Vsynth-Tools/vocaloid-integrity-check/issues
9
+ Keywords: vocaloid,voicebank,ddi,ddb,integrity,md5
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: End Users/Desktop
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Topic :: Multimedia :: Sound/Audio
18
+ Classifier: Topic :: Security
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # vocaloid-integrity-check
25
+
26
+ Check a Vocaloid voicebank when you’re concerned that it may be corrupted or was renamed.
27
+
28
+ Standard library only. Python 3.10+.
29
+
30
+ ## Install
31
+
32
+ ```console
33
+ $ pip install vocaloid-integrity-check
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ```console
39
+ $ vocaloid-integrity-check Yuki.ddi --ddb Yuki.ddb
40
+ hash verified
41
+ name : Yuki (root ARR4)
42
+ stored : 92942a5a960cdf938b3d742d8a75f5df
43
+ expect : 92942a5a960cdf938b3d742d8a75f5df
44
+ ```
45
+
46
+ `--json` prints machine-readable output. If `--ddb` is omitted, the `.ddi` filename is used.
47
+
48
+ ## Results
49
+
50
+ - `hash verified` — the check succeeded.
51
+ - `hash fail` — the check found a mismatch.
52
+ - `hash present, not checkable` — a value is present, but cannot be judged from the files alone (Vocaloid 3/4).
53
+ - `hash not present` — no value was found.
54
+ - `hash not verifiable` — the name cannot be checked in the current environment.
55
+
56
+ Exit status: `0` verified, `1` fail, `2` inconclusive or invalid input.
57
+
58
+ Vocaloid 2 banks are checked. Vocaloid 3/4 banks are recognized, but reported as not checkable rather than verified or failed.
59
+
60
+ ## Notes
61
+
62
+ This is an integrity check, not an authenticity check. `unity-chan_for_Unity` is a known exception; treat a mismatch for it as unknown.
63
+
64
+ ## License
65
+
66
+ MIT.
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/vocaloid_integrity_check/__init__.py
5
+ src/vocaloid_integrity_check/__main__.py
6
+ src/vocaloid_integrity_check/checker.py
7
+ src/vocaloid_integrity_check/cli.py
8
+ src/vocaloid_integrity_check.egg-info/PKG-INFO
9
+ src/vocaloid_integrity_check.egg-info/SOURCES.txt
10
+ src/vocaloid_integrity_check.egg-info/dependency_links.txt
11
+ src/vocaloid_integrity_check.egg-info/entry_points.txt
12
+ src/vocaloid_integrity_check.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ vocaloid-integrity-check = vocaloid_integrity_check.cli:main