Skip to main content
Scramjet uses URL codecs to encode real URLs into proxy URLs and decode them back. You can customize this behavior by providing your own encoding and decoding functions.

Default codec

By default, Scramjet uses simple URL encoding:
With the default codec and prefix /scramjet/, a URL like https://example.com becomes:

Creating a custom codec

Custom codecs are defined when creating the ScramjetController:
The encoder and decoder functions must be inverse operations - what you encode must be decodable back to the original URL.

Common codec implementations

Base64 encoding

Base64 encoding makes URLs more obfuscated:

XOR cipher encoding

Add simple obfuscation with an XOR cipher:
XOR cipher provides minimal security and should not be relied upon for actual encryption. Use it only for obfuscation.

Plain encoding

For maximum compatibility and debugging, use plain text URLs:
Plain encoding requires special web server configuration to handle URLs containing :// and other special characters.

Custom delimiter encoding

Use a custom delimiter instead of URL encoding:

Hash fragment handling

Scramjet automatically handles URL hash fragments separately:
Your codec doesn’t need to handle hash fragments - Scramjet manages them automatically:

Using the controller’s encode/decode methods

The ScramjetController provides helper methods for encoding and decoding URLs:
Use these methods instead of calling your codec functions directly to ensure proper prefix handling.

Protocol handling

Scramjet only proxies HTTP and HTTPS URLs. Other protocols are passed through unchanged:

Testing your codec

Here’s a test suite for validating your custom codec:

Performance considerations

The codec functions are called frequently during page loads. Keep them fast:
Some codecs increase URL length significantly:
Long URLs may cause issues with some servers or browsers.
Always handle edge cases:

Basic setup

Learn how to configure Scramjet

Configuration flags

Explore other configuration options