macserialrb 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a5313b9a53329d6a3d80afd261da0deccf1eac05b98e937ec7e87402c004d06c
4
+ data.tar.gz: 97a10ed4be0c861fde5fade364f09f0b8ec1ba5940f14f623f7942edfe5dd4d7
5
+ SHA512:
6
+ metadata.gz: 28bfc78771ccf4c8e3a4b4a994b7cd62e17e3cf4d959cb173fefef4ce64be2371a35a589087f1e1fda35ec081eef89d592335d4fe04a847b7f52a6c272ef1fd8
7
+ data.tar.gz: 6246396bb8a897baa0d15720a259cfb60ed75e83cbaaa92fe14745ed947720068f5a5267c35251cfc361ca53000c6551387e63edf4cf0253802ebd86a6463929
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.bundle
10
+ *.so
11
+ *.o
12
+ *.a
13
+ mkmf.log
14
+
15
+ # rspec failure tracking
16
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.2
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at csrutil@protonmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in macserialrb.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rake-compiler"
8
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ macserialrb (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.4.4)
10
+ rake (12.3.3)
11
+ rake-compiler (1.1.1)
12
+ rake
13
+ rspec (3.10.0)
14
+ rspec-core (~> 3.10.0)
15
+ rspec-expectations (~> 3.10.0)
16
+ rspec-mocks (~> 3.10.0)
17
+ rspec-core (3.10.0)
18
+ rspec-support (~> 3.10.0)
19
+ rspec-expectations (3.10.0)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.10.0)
22
+ rspec-mocks (3.10.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.10.0)
25
+ rspec-support (3.10.0)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ macserialrb!
32
+ rake (~> 12.0)
33
+ rake-compiler
34
+ rspec (~> 3.0)
35
+
36
+ BUNDLED WITH
37
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 csrutil
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,63 @@
1
+ # Macserialrb
2
+
3
+ This is the Ruby version of the macserial, you can check the [source](https://github.com/acidanthera/OpenCorePkg/tree/master/Utilities/macserial) here
4
+
5
+ ## Usage
6
+
7
+ List all the models
8
+
9
+ ```ruby
10
+ Macserialrb.models
11
+ ```
12
+
13
+ Generate SystemSerialNumber and MLB
14
+
15
+ ```ruby
16
+ Macserialrb.generate model: "iMac19,1"
17
+
18
+ {
19
+ productName: "iMac19,1",
20
+ SystemSerialNumber: "C02YRRYRJV3Q",
21
+ MLB: "C02921306QXLNV9A8"
22
+ }
23
+ ```
24
+
25
+ Todo
26
+
27
+ - Add the year option
28
+
29
+ ## Installation
30
+
31
+ Add this line to your application's Gemfile:
32
+
33
+ ```ruby
34
+ gem 'macserialrb'
35
+ ```
36
+
37
+ And then execute:
38
+
39
+ $ bundle install
40
+
41
+ Or install it yourself as:
42
+
43
+ $ gem install macserialrb
44
+
45
+
46
+ ## Development
47
+
48
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49
+
50
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/csrutil/macserialrb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/csrutil/macserialrb/blob/master/CODE_OF_CONDUCT.md).
55
+
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
60
+
61
+ ## Code of Conduct
62
+
63
+ Everyone interacting in the Macserialrb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/csrutil/macserialrb/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ require "rake/extensiontask"
7
+
8
+ task :build => :compile
9
+
10
+ Rake::ExtensionTask.new("macserialrb") do |ext|
11
+ ext.lib_dir = "lib/macserialrb"
12
+ end
13
+
14
+ task :default => [:clobber, :compile, :spec]
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "macserialrb"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "macserialrb"
@@ -0,0 +1,11 @@
1
+ require "mkmf"
2
+
3
+ case RUBY_PLATFORM
4
+ when /linux/i
5
+ $CPPFLAGS += ' -std=c11 -Werror -Wall'
6
+ when /darwin/i
7
+ $CPPFLAGS += ' -std=c11 -Werror -Wall'
8
+ end
9
+
10
+
11
+ create_makefile("macserialrb/macserialrb")
@@ -0,0 +1,221 @@
1
+ Apple Mac Serial Format
2
+ =======================
3
+
4
+ It is reasonably important to get more information about the goods you buy, especially if they are not new, and you do not have absolute confidence in the seller. Serial numbers are the first thing to look at. For Apple products [Apple Check Coverage](https://checkcoverage.apple.com) is your best friend.
5
+
6
+ However, it does not show all the details encoded in the serial, and in some case it may be important. For example, certain shady dealers may change one valid serial by the other, and it will not be obvious at a glance that the serial does not belong to the actual model. This FAQ attempts to explain the reverse-engineered structure of the serials used in Apple hardware.
7
+
8
+ You could always receive information about the current serial number of your Mac by running `./macserial`. For the other serial use `./macserial -i SERIALNUMBER`, where `SERIALNUMBER` is the serial you check.
9
+
10
+ ## Apple base 34
11
+
12
+ Select fields in the numbers are encoded values in base 34. So, certain alpha-numeric characters represent a slightly uncommon base 34 code excluding `O` and `I`.
13
+
14
+ | Char | Value | Char | Value |
15
+ | ---- | ----- | ---- | ----- |
16
+ | `0` | `0` | `H` | `17` |
17
+ | `1` | `1` | `J` | `18` |
18
+ | `2` | `2` | `K` | `19` |
19
+ | `3` | `3` | `L` | `20` |
20
+ | `4` | `4` | `M` | `21` |
21
+ | `5` | `5` | `N` | `22` |
22
+ | `6` | `6` | `P` | `23` |
23
+ | `7` | `7` | `Q` | `24` |
24
+ | `8` | `8` | `R` | `25` |
25
+ | `9` | `9` | `S` | `26` |
26
+ | `A` | `10` | `T` | `27` |
27
+ | `B` | `11` | `U` | `28` |
28
+ | `C` | `12` | `V` | `29` |
29
+ | `D` | `13` | `W` | `30` |
30
+ | `E` | `14` | `X` | `31` |
31
+ | `F` | `15` | `Y` | `32` |
32
+ | `G` | `16` | `Z` | `33` |
33
+
34
+ ## Serial number (SN)
35
+
36
+ There generally are 2 similar formats of serial encoding: the old 11 character format, and the new 12 character format.
37
+
38
+ | Type | Location | Year | Week | Line | Product |
39
+ | --------- | --------- | ---- | ---- | ----- | -------- |
40
+ | Old (11) | `LL` | `Y` | `WW` | `SSS` | `PPP` |
41
+ | New (12) | `LLL` | `Y` | `W` | `SSS` | `PPPP` |
42
+
43
+ ### Location
44
+
45
+ This value encodes the manufacturing location, which is often more descriptive than `Made in China`, since it may reveal the responsible company and the city. For example, `F5K` means `USA (Flextronics)` and `QT` means `Taiwan (Quanta Computer)`. The list is not standardised or published anywhere, but you can see several known locations by running `./macserial -l`.
46
+
47
+ One of the important locations for old-style serials (11 characters) is `RM`. It means that the model was refurbished. For new-style serials you have to call [Apple support](https://support.apple.com) to know this.
48
+
49
+ ### Year
50
+
51
+ Year encodes the actual manufacturing year of each model. For refurbished models it is unknown whether it is replaced by the remanufacturing year.
52
+
53
+ For old-style serials it always is a digit that encodes the last digit of the year. For example, `8` means 2008 and `1` means 2011. Only `0` to `9` digitis are used for year encoding. Old-style serials are out of use starting with 2013, so `3` means 2003 not 2013.
54
+
55
+ | Char | Year |
56
+ | ---- | ---- |
57
+ | `3` | 2003 |
58
+ | `4` | 2004 |
59
+ | `5` | 2005 |
60
+ | `6` | 2006 |
61
+ | `7` | 2007 |
62
+ | `8` | 2008 |
63
+ | `9` | 2009 |
64
+ | `0` | 2010 |
65
+ | `1` | 2011 |
66
+ | `2` | 2012 |
67
+
68
+
69
+ For new-style serials it is an alphanumeric value, which not only encodes the year, but its half as well. Not all the values are allowed. The table below outlines the pairs of characters which are assumed to encode each supported year. First character in the pair is believed to encode the first half of the year, and the second character — the second half.
70
+
71
+ | Pair | Year |
72
+ | -------- | ---- |
73
+ | `C`, `D` | 2010 |
74
+ | `F`, `G` | 2011 |
75
+ | `H`, `J` | 2012 |
76
+ | `K`, `L` | 2013 |
77
+ | `M`, `N` | 2014 |
78
+ | `P`, `Q` | 2015 |
79
+ | `R`, `S` | 2016 |
80
+ | `T`, `V` | 2017 |
81
+ | `W`, `X` | 2018 |
82
+ | `Y`, `Z` | 2019 |
83
+ | `C`, `D` | 2020 |
84
+
85
+ ### Week
86
+
87
+ Week encodes the actual manufacturing week of each model. This week has nothing in common with [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date), and appears to be encoded literally as 7-day sequences starting from January, 1st. Since each year has either 365 or 366 days, 53rd week is extremely rare, and you are lucky to have such a serial.
88
+
89
+ For old-style serials week is encoded in plain numeric digits with leading zeroes. `01`, `02`, ... `53`. For new-style serials an alpha-numeric code is used. Encoded year half also counts and means adds 26 weeks for the second one.
90
+
91
+ | Char | 1st half | 2nd half |
92
+ | ---- | -------- | -------- |
93
+ | `1` | `1` | `27` |
94
+ | `2` | `2` | `28` |
95
+ | `3` | `3` | `29` |
96
+ | `4` | `4` | `30` |
97
+ | `5` | `5` | `31` |
98
+ | `6` | `6` | `32` |
99
+ | `7` | `7` | `33` |
100
+ | `8` | `8` | `34` |
101
+ | `9` | `9` | `35` |
102
+ | `C` | `10` | `36` |
103
+ | `D` | `11` | `37` |
104
+ | `F` | `12` | `38` |
105
+ | `G` | `13` | `39` |
106
+ | `H` | `14` | `40` |
107
+ | `J` | `15` | `41` |
108
+ | `K` | `16` | `42` |
109
+ | `L` | `17` | `43` |
110
+ | `M` | `18` | `44` |
111
+ | `N` | `19` | `45` |
112
+ | `P` | `20` | `46` |
113
+ | `Q` | `21` | `47` |
114
+ | `R` | `22` | `48` |
115
+ | `T` | `23` | `49` |
116
+ | `V` | `24` | `50` |
117
+ | `W` | `25` | `51` |
118
+ | `X` | `26` | `52` |
119
+ | `Y` | `-` | `53` |
120
+
121
+ For old-style serials it is a pair of two digits, which encode the manufacturing week.
122
+
123
+ ### Production line and copy
124
+
125
+ Production line is believed to be related to some identifier at assembly stage. It is encoded in base 34, but the actual derivation process is unknown and can only be guessed with relative success.
126
+
127
+ Current model, which apparently works well, represents it as a sum of three alpha-numeric characters with `1`, `34`, and `68` multipliers. The actual formula looks as follows:
128
+
129
+ ```
130
+ base34[S1] * 68 + base34[S2] * 34 + base34[S3] = production line
131
+ ```
132
+
133
+ This formula effectively defines a compression function, which allows to encode a total of `3400` production lines from `0` to `3399`. The compression produced by shortening `39304` space to `3400` allows multiple encodings of the same line. For example, for `939` line there can be `14` derivatives or "copies": `0TM`, `1RM`, `2PM`, `3MM`, `4KM`, ..., `D1M`.
134
+
135
+ While the formula does look strange, it was experimentally discovered that up to `N` first encoded derivatives are valid, and starting with the first invalid derivative there will be no valid ones. Thus for a complete serial list made up with all the derivatives from the above the following is assumed to be true: if `0TM` and `2PM` are valid and `3MM` is invalid, then `1RM` will also be valid, and `4KM` to `D1M` will be invalid. From this data it could be theorised that the encoded value is incremented for each model produced from the same line. So `0TM` is the first copy produced, and `D1M` is the last copy.
136
+
137
+ **Update**: At a later stage very few examples of valid derivatives after invalid were found. These exceptions disprove at least some parts of the model, but currently there exists no better theory.
138
+
139
+ ### Product model
140
+
141
+ Last 3 (for legacy serials) or 4 (for new serials) symbols encode the actual product identifier of this exact piece of the hardware. This is probably the most useful part of the serial, since it allows you to get the detailed description of your hardware directly from the dedicated Apple Specs portal. To do so you need to modify the following URI to contain your real product code instead of `PPPP` and follow it in your browser:
142
+
143
+ ```
144
+ http://support-sp.apple.com/sp/index?page=cpuspec&cc=PPPP
145
+ ```
146
+
147
+ For example, for iMacPro1,1 it could be [HX87](http://support-sp.apple.com/sp/index?page=cpuspec&cc=HX87) and for MacBookPro14,3 it could be [HTD5](http://support-sp.apple.com/sp/index?page=cpuspec&cc=HTD5).
148
+
149
+ The list is not standardised or published anywhere, but you can see most products by running `./macserial -lp` and `./macserial -l` to match against mac models. The value seems to be a classic base 34 sequence: `P1 * 39304 + P2 * 1156 + P3 * 34 + P4`. The ranges seem to be allocated in chunks in non-decreasing manner. Normally each chunk is distanced from another chunk by up to 64 (90% matches).
150
+
151
+ ## Logic board serial number (MLB)
152
+
153
+ There generally are 2 formats of logic board serial encoding: the old 13 character format, and the new 17 character format. Unlike serial number, these formats are quite different and in addition very little is known about MLB in general.
154
+
155
+ | Type | Location | Year | Week | Item | Infix | Product | Suffix |
156
+ | --------- | --------- | ---- | ---- | ------ | ------ | -------- | ------ |
157
+ | Old (13) | `LL` | `Y` | `WW` | `IIII` | | `EEE` | `C` |
158
+ | New (17) | `LLL` | `Y` | `WW` | `III` | `AA` | `EEEE` | `CC` |
159
+
160
+ While it is unclear if this is intentional, for 17 character MLB it is possible to perform basic validation online through `osrecovery.apple.com`. The recovery server will return valid latest recovery image only when MLB is valid. Use `./macrecovery.py verify -m MLB -b BOARD-ID` to try verifying your MLB number.
161
+
162
+ It is not clear how strongly MLB is attached to serial number (SN). The following is known:
163
+
164
+ - Minimal supported macOS version is identified by `EEEE`
165
+ - Maximum supported macOS version is identified by `EEEE` and `board-id`
166
+ - Recovery server accepts a range of models with the same MLB (with only latest os different)
167
+
168
+ The following is suspected:
169
+ - `EEEE` is unique number for all MLBs
170
+ - `EEEE` are shared across different models and thus cannot identify the model
171
+
172
+ ### Location
173
+
174
+ MLB location is equivalent to serial number location but does not necessarily match it, as logic boards can be manufactured at a different place.
175
+
176
+ ### Year and week
177
+
178
+ MLB year and week in both 13-character and 17-character MLB are equivalent to legacy serial number year and week. The values are slightly lower as logic board is manufactured prior to the complete product.
179
+
180
+ ### Item
181
+
182
+ MLB item is encoded differently for 13-character and 17-character MLB. It might serve as a production item per week and could be similar to 'Production line and copy' in the serial number.
183
+
184
+ - For old MLB, this is a variant of base 34 value. First item character is always `0`.
185
+ - For new MLB, this value always is a number.
186
+
187
+ ### Infix
188
+
189
+ Base 34 value present in new MLBs only. No information is known about it. Could actually be part of Item.
190
+
191
+ ### Product board
192
+
193
+ Similarly to 'Product model' this field encodes logic board model number. This code is often referred to as `EEE code` in part catalogues and is useful for purchasing a compatible logic board for replacement.
194
+
195
+ For new 17 character MLBs this field is also used for identification at `osrecovery.apple.com` to provide a compatible internet recovery image and diagnostic tools upon request.
196
+
197
+ ### Suffix
198
+
199
+ Base 34 value with unclear designation. Might be used for checksum validation. Checksum validation algorithm is reverse engineered from diagnostics tools and is valid for all 17 character MLBs. It is not clear whether 13 character MLBs have any checksum. 17 character MLB checksum follows.
200
+
201
+ ```C
202
+ static bool verify_mlb_checksum(const char *mlb, size_t len) {
203
+ const char alphabet[] = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
204
+ size_t checksum = 0;
205
+ for (size_t i = 0; i < len; ++i) {
206
+ for (size_t j = 0; j <= sizeof (alphabet); ++j) {
207
+ if (j == sizeof (alphabet))
208
+ return false;
209
+ if (mlb[i] == alphabet[j]) {
210
+ checksum += (((i & 1) == (len & 1)) * 2 + 1) * j;
211
+ break;
212
+ }
213
+ }
214
+ }
215
+ return checksum % (sizeof(alphabet) - 1) == 0;
216
+ }
217
+ ```
218
+
219
+ ## Appendix
220
+
221
+ This information was obtained experimentally and may not be accurate in certain details. Be warned that it is published at no warranty for educational and introductory purposes only.