ps2_bios_checksum 1.0.0

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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +28 -0
  4. data/lib/ps2_bios_checksum.rb +61 -0
  5. metadata +50 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b5d3087cb82469861642c7132c6f5f3467bf1dd9b5d89588ec08a49a3a5687bc
4
+ data.tar.gz: 3f33b1558d09f0a684adba46fc38ecb0b207949c08c1510a1849e08b654b0ff1
5
+ SHA512:
6
+ metadata.gz: 2351f0cc0d6ab6f43d60913beea0740bab1a0d48774a0f660e990a7324c93116ed3e693f78b6c2fc7fab7fff088e8d9e5ca1d277e58cb9a888106cfd62b84b6d
7
+ data.tar.gz: a17cd583464a6207f290f9a46845cd0e8efeadaff9121ae1877de50d88e4c224a03757cf9bac95c3f948e1ffe1e6a746246476b860985be82917310a944f39ab
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AllPS2BIOS
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.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # ps2_bios_checksum (RubyGems)
2
+
3
+ Ruby helpers for inspecting a local PS2 BIOS dump: MD5, SHA-1, and basic dump-size checks.
4
+
5
+ Does **not** include or download BIOS files.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ gem install ps2_bios_checksum
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ruby
16
+ require "ps2_bios_checksum"
17
+
18
+ result = Ps2BiosChecksum.hash_file("SCPH-70000.bin")
19
+ puts "#{result[:md5]} #{result[:validation][:summary]}"
20
+ ```
21
+
22
+ ## Docs
23
+
24
+ RetroArch PS2 BIOS notes: [https://allps2bios.com/ps2-bios-retroarch/](https://allps2bios.com/ps2-bios-retroarch/)
25
+
26
+ ## License
27
+
28
+ MIT
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ps2BiosChecksum
4
+ COMMON_BIOS_SIZES = [
5
+ 2 * 1024 * 1024,
6
+ 4 * 1024 * 1024,
7
+ 8 * 1024 * 1024,
8
+ 16 * 1024 * 1024
9
+ ].freeze
10
+
11
+ module_function
12
+
13
+ def format_file_size(bytes)
14
+ return "#{bytes} B" if bytes < 1024
15
+
16
+ kib = bytes / 1024.0
17
+ return format("%.2f KB", kib) if kib < 1024
18
+
19
+ format("%.2f MB", kib / 1024.0)
20
+ end
21
+
22
+ def validate_bios_size(size_bytes)
23
+ if size_bytes <= 0
24
+ return {
25
+ ok: false,
26
+ summary: "File is empty",
27
+ detail: "An empty file cannot be used as a BIOS image. Basic check only."
28
+ }
29
+ end
30
+
31
+ if COMMON_BIOS_SIZES.include?(size_bytes)
32
+ return {
33
+ ok: true,
34
+ summary: "Basic checks passed",
35
+ detail: "Size matches a commonly reported PS2 BIOS dump size. Not proof of authenticity."
36
+ }
37
+ end
38
+
39
+ {
40
+ ok: false,
41
+ summary: "File size does not match common BIOS sizes",
42
+ detail: "Common sizes are 2, 4, 8, or 16 MiB. Unexpected size may mean incomplete or non-BIOS data."
43
+ }
44
+ end
45
+
46
+ def hash_bytes(data, path: nil)
47
+ require "digest"
48
+ bytes = data.b
49
+ {
50
+ size_bytes: bytes.bytesize,
51
+ md5: Digest::MD5.hexdigest(bytes),
52
+ sha1: Digest::SHA1.hexdigest(bytes),
53
+ validation: validate_bios_size(bytes.bytesize),
54
+ path: path
55
+ }
56
+ end
57
+
58
+ def hash_file(path)
59
+ hash_bytes(File.binread(path), path: path)
60
+ end
61
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ps2_bios_checksum
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - AllPS2BIOS
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-09-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Hash a local PS2 BIOS dump and run basic dump-size checks. Does not include
14
+ BIOS files.
15
+ email:
16
+ - support@allps2bios.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE
22
+ - README.md
23
+ - lib/ps2_bios_checksum.rb
24
+ homepage: https://allps2bios.com/ps2-bios-retroarch/
25
+ licenses:
26
+ - MIT
27
+ metadata:
28
+ homepage_uri: https://allps2bios.com/ps2-bios-retroarch/
29
+ source_code_uri: https://github.com/nbkdevs/ps2-bios-assistant
30
+ changelog_uri: https://github.com/nbkdevs/ps2-bios-assistant
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 3.0.0
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubygems_version: 3.4.19
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Local PS2 BIOS checksum helpers (MD5, SHA-1, size checks).
50
+ test_files: []