https://github.com/antikirra/base64url
Base64url implementation for PHP
https://github.com/antikirra/base64url
base64url encoding php serialization
Last synced: 5 months ago
JSON representation
Base64url implementation for PHP
- Host: GitHub
- URL: https://github.com/antikirra/base64url
- Owner: antikirra
- Created: 2023-05-17T16:47:12.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-10-19T09:15:19.000Z (8 months ago)
- Last Synced: 2025-10-19T20:06:38.406Z (8 months ago)
- Topics: base64url, encoding, php, serialization
- Language: PHP
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Base64URL | URL-Safe Base64 Encoding



**Ultra-lightweight PHP library for URL-safe base64 encoding and decoding.** Perfect for JWT tokens, URL parameters, API keys, and any scenario requiring base64 encoding without URL-unsafe characters (+, /, =).
## Install
```console
composer require antikirra/base64url:^2.0
```
## Why Base64URL?
- ✨ **URL-Safe** - No special characters that need URL encoding
- 🔧 **RFC 4648 Compliant** - Follows official base64url specification
- ⚡ **Blazing Fast** - Minimal overhead, optimized string operations
- 🎯 **Drop-in Replacement** - Simple API, easy migration from base64_encode/decode
- 📦 **Lightweight** - Just 2 functions, zero dependencies
- 🚀 **Production Ready** - Battle-tested in JWT and API implementations
## Features
- **URL-Safe Encoding**: Replaces `+` with `-` and `/` with `_`, removes padding `=`
- **Input Validation**: Strict validation prevents invalid characters in decoding
- **UTF-8 Support**: Handles multibyte characters correctly (Chinese, Korean, Japanese, etc.)
- **Binary Safe**: Works with any binary data, not just text
- **Legacy Compatible**: Works with PHP 5.6+ through PHP 8.4
- **Zero Dependencies**: No external libraries or extensions required
- **100% Test Coverage**: Fully tested with comprehensive test suite
## Perfect for
- **JWT Tokens**: Encoding JWT payloads and signatures
- **URL Parameters**: Safely encode data in query strings
- **API Keys**: Generate URL-safe API tokens and keys
- **OAuth**: State parameters and authorization codes
- **File Names**: Encode data for use in file names
- **Cookies**: Store encoded data in cookies without escaping
## Requirements
- **PHP**: 5.6 or higher
- **Extensions**: None (uses only core PHP functions)
- **Dependencies**: Zero
## Basic usage
```php