Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Windows Script Encoder for PHP

A small, dependency-free PHP class for encoding and decoding standalone Microsoft Script Encoder blocks, such as data commonly found in .vbe and .jse files.

This project provides a single WindowsScriptEncoder class with two public methods:

  • WindowsScriptEncoder::encode(string $plain, ?int $codePage = null): string
  • WindowsScriptEncoder::decode(string $encoded, ?int $codePage = null): string

It is byte-oriented, validates encoded block metadata, and supports optional DBCS lead-byte handling for legacy Windows code pages.

Features

  • Encode plain script bytes into a standalone Script Encoder block.
  • Decode standalone Script Encoder blocks back to plain script bytes.
  • Validates block markers, encoded length, checksum fields, and escape sequences.
  • Uses fixed little-endian 32-bit packing for length and checksum fields.
  • Handles Script Encoder escape sequences such as @#, @&, @!, @*, and @$.
  • Supports optional DBCS code page handling for legacy Windows scripts:
    • 932 Japanese Shift-JIS
    • 936 Simplified Chinese GBK/GB2312 family
    • 949 Korean
    • 950 Traditional Chinese Big5
    • 1361 Korean Johab
  • No external dependencies.
  • No Composer package is required.

Requirements

  • PHP 8.0 or later.

The class uses PHP 8 features such as match, str_starts_with(), and str_ends_with().

About

Microsoft Script Encoder / Decoder in PHP

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages