Download the PHP package vlydev/cs2-masked-inspect without Composer
On this page you can find all versions of the php package vlydev/cs2-masked-inspect. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cs2-masked-inspect
cs2-masked-inspect (PHP)
Pure PHP 8.2+ library for encoding and decoding CS2 masked inspect links — no runtime dependencies.
Installation
Usage
Deserialize a CS2 inspect link
Serialize an item to a hex payload
Item with stickers and keychains
Gen codes
Gen codes are space-separated command strings used on CS2 community servers to spawn items.
Format:
- Stickers are always represented as 5 slot pairs (padded with
0 0for empty slots) - Keychains are appended without padding, only for present slots
- Float values have trailing zeros stripped (max 8 decimal places);
0.0becomes"0"
Generate a Steam inspect URL from parameters
Convert an ItemPreviewData to a gen code
Parse a gen code string
Convert an existing inspect link directly to a gen code
Validation
Use isMasked() and isClassic() to detect the link type without attempting to decode it.
Validation rules
deserialize() enforces:
| Rule | Limit | Exception |
|---|---|---|
| Hex payload length | max 4,096 characters | InvalidArgumentException |
| Protobuf field count | max 100 per message | OverflowException |
serialize() enforces:
| Field | Constraint | Exception |
|---|---|---|
paintwear |
[0.0, 1.0] |
InvalidArgumentException |
customname |
max 100 characters | InvalidArgumentException |
How the format works
Three URL formats are handled:
-
New masked format — pure hex blob after
csgo_econ_action_preview: -
Hybrid format — old-style
S/A/Dprefix, but with a hex proto appended afterD(instead of a decimal did): - Classic format — old-style
S/A/Dwith a decimal did; requires Steam GC to resolve item details.
For formats 1 and 2 the library decodes the item offline. For format 3 only URL parsing is possible.
The hex blob (formats 1 and 2) has the following binary layout:
| Section | Size | Description |
|---|---|---|
key_byte |
1 byte | XOR key. 0x00 = no obfuscation (tool links). Other values = native CS2 links. |
proto_bytes |
variable | CEconItemPreviewDataBlock protobuf, each byte XOR'd with key_byte. |
checksum |
4 bytes | Big-endian uint32, XOR'd with key_byte. |
Checksum algorithm
paintwear encoding
paintwear is stored as a uint32 varint whose bit pattern is the IEEE 754 representation
of a float32. The library handles this transparently — callers always work with PHP float values.
Proto field reference
CEconItemPreviewDataBlock
| Field | Number | Type | Description |
|---|---|---|---|
accountid |
1 | uint32 | Steam account ID (often 0) |
itemid |
2 | uint64 | Item ID in the owner's inventory |
defindex |
3 | uint32 | Item definition index (weapon type) |
paintindex |
4 | uint32 | Skin paint index |
rarity |
5 | uint32 | Item rarity |
quality |
6 | uint32 | Item quality |
paintwear |
7 | uint32* | float32 reinterpreted as uint32 |
paintseed |
8 | uint32 | Pattern seed (0–1000) |
killeaterscoretype |
9 | uint32 | StatTrak counter type |
killeatervalue |
10 | uint32 | StatTrak value |
customname |
11 | string | Name tag |
stickers |
12 | repeated Sticker | Applied stickers |
inventory |
13 | uint32 | Inventory flags |
origin |
14 | uint32 | Origin |
questid |
15 | uint32 | Quest ID |
dropreason |
16 | uint32 | Drop reason |
musicindex |
17 | uint32 | Music kit index |
entindex |
18 | int32 | Entity index |
petindex |
19 | uint32 | Pet index |
keychains |
20 | repeated Sticker | Applied keychains |
Sticker
| Field | Number | Type | Description |
|---|---|---|---|
slot |
1 | uint32 | Slot position |
sticker_id |
2 | uint32 | Sticker definition ID |
wear |
3 | float32 | Wear (fixed32) |
scale |
4 | float32 | Scale (fixed32) |
rotation |
5 | float32 | Rotation (fixed32) |
tint_id |
6 | uint32 | Tint |
offset_x |
7 | float32 | X offset (fixed32) |
offset_y |
8 | float32 | Y offset (fixed32) |
offset_z |
9 | float32 | Z offset (fixed32) |
pattern |
10 | uint32 | Pattern (keychains) |
Known test vectors
Vector 1 — Native CS2 link (XOR key 0xE3)
| Field | Value |
|---|---|
itemid |
46876117973 |
defindex |
7 (AK-47) |
paintindex |
422 |
paintseed |
922 |
paintwear |
≈ 0.04121 |
rarity |
3 |
quality |
4 |
| sticker IDs | [7436, 5144, 6970, 8069, 5592] |
Vector 2 — Tool-generated link (key 0x00)
Expected hex:
Running tests
Contributing
Bug reports and pull requests are welcome on GitHub.
- Fork the repository
- Create a branch:
git checkout -b my-fix - Make your changes and add tests
- Ensure all tests pass:
composer test - Open a Pull Request
All PRs require the CI checks to pass before merging.
Author
License
MIT © VlyDev