{"id":35873341,"url":"https://github.com/antikirra/base64url","last_synced_at":"2026-01-20T17:31:49.821Z","repository":{"id":166526342,"uuid":"642023647","full_name":"antikirra/base64url","owner":"antikirra","description":"Base64url implementation for PHP","archived":false,"fork":false,"pushed_at":"2025-10-19T09:15:19.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T20:06:38.406Z","etag":null,"topics":["base64url","encoding","php","serialization"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antikirra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-17T16:47:12.000Z","updated_at":"2025-10-19T09:15:13.000Z","dependencies_parsed_at":"2025-10-19T11:11:15.043Z","dependency_job_id":"f597b619-e2f8-45b8-9072-ff3b15b16999","html_url":"https://github.com/antikirra/base64url","commit_stats":null,"previous_names":["antikirra/base64url"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/antikirra/base64url","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antikirra%2Fbase64url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antikirra%2Fbase64url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antikirra%2Fbase64url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antikirra%2Fbase64url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antikirra","download_url":"https://codeload.github.com/antikirra/base64url/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antikirra%2Fbase64url/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28246677,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2026-01-08T02:00:06.591Z","response_time":241,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base64url","encoding","php","serialization"],"created_at":"2026-01-08T16:01:23.853Z","updated_at":"2026-01-08T16:04:52.766Z","avatar_url":"https://github.com/antikirra.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Base64URL | URL-Safe Base64 Encoding\n\n![Packagist Dependency Version](https://img.shields.io/packagist/dependency-v/antikirra/base64url/php)\n![Packagist Version](https://img.shields.io/packagist/v/antikirra/base64url)\n![Code Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)\n\n**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 (+, /, =).\n\n## Install\n\n```console\ncomposer require antikirra/base64url:^2.0\n```\n\n## Why Base64URL?\n\n- ✨ **URL-Safe** - No special characters that need URL encoding\n- 🔧 **RFC 4648 Compliant** - Follows official base64url specification\n- ⚡ **Blazing Fast** - Minimal overhead, optimized string operations\n- 🎯 **Drop-in Replacement** - Simple API, easy migration from base64_encode/decode\n- 📦 **Lightweight** - Just 2 functions, zero dependencies\n- 🚀 **Production Ready** - Battle-tested in JWT and API implementations\n\n## Features\n\n- **URL-Safe Encoding**: Replaces `+` with `-` and `/` with `_`, removes padding `=`\n- **Input Validation**: Strict validation prevents invalid characters in decoding\n- **UTF-8 Support**: Handles multibyte characters correctly (Chinese, Korean, Japanese, etc.)\n- **Binary Safe**: Works with any binary data, not just text\n- **Legacy Compatible**: Works with PHP 5.6+ through PHP 8.4\n- **Zero Dependencies**: No external libraries or extensions required\n- **100% Test Coverage**: Fully tested with comprehensive test suite\n\n## Perfect for\n\n- **JWT Tokens**: Encoding JWT payloads and signatures\n- **URL Parameters**: Safely encode data in query strings\n- **API Keys**: Generate URL-safe API tokens and keys\n- **OAuth**: State parameters and authorization codes\n- **File Names**: Encode data for use in file names\n- **Cookies**: Store encoded data in cookies without escaping\n\n## Requirements\n\n- **PHP**: 5.6 or higher\n- **Extensions**: None (uses only core PHP functions)\n- **Dependencies**: Zero\n\n## Basic usage\n\n```php\n\u003c?php\n\nuse function Antikirra\\base64url_decode;\nuse function Antikirra\\base64url_encode;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n// Encode text (including UTF-8)\necho base64url_encode('Hello World!'); // SGVsbG8gV29ybGQh\necho base64url_encode('火 剄る 불');    // 54GrIOWJhOOCiyDrtog\n\n// Decode back\necho base64url_decode('SGVsbG8gV29ybGQh'); // Hello World!\necho base64url_decode('54GrIOWJhOOCiyDrtog'); // 火 剄る 불\n\n// Invalid input returns false\nvar_dump(base64url_decode('invalid@chars!')); // bool(false)\n```\n\n## API Reference\n\n### `base64url_encode(string $string): string`\n\nEncodes a string using URL-safe base64 encoding.\n\n**Parameters:**\n- `$string` - The string to encode (binary-safe)\n\n**Returns:**\n- URL-safe base64 encoded string (no `+`, `/`, or `=` characters)\n\n**Example:**\n```php\nbase64url_encode('test'); // dGVzdA\n```\n\n### `base64url_decode(string $string): string|false`\n\nDecodes a URL-safe base64 encoded string.\n\n**Parameters:**\n- `$string` - The base64url encoded string\n\n**Returns:**\n- Decoded string on success, `false` on invalid input\n\n**Example:**\n```php\nbase64url_decode('dGVzdA'); // test\nbase64url_decode('inv@lid'); // false\n```\n\n## Testing\n\nThe library is thoroughly tested with comprehensive test coverage:\n\n- **Test Framework**: Pest\n- **Total Tests**: 16 passing\n- **Code Coverage**: 100% (lines and functions)\n\n### Test Categories\n\n- **Basic Functionality**: Encoding and decoding operations\n- **UTF-8 Support**: Multibyte character handling\n- **Edge Cases**: Empty strings, padding scenarios\n- **Input Validation**: Invalid character detection\n- **Round-trip Tests**: Encode → Decode consistency\n- **Binary Safety**: Handling non-text data\n\n## Comparison: Standard Base64 vs Base64URL\n\n| Feature | base64_encode/decode | base64url_encode/decode |\n|---------|---------------------|------------------------|\n| URL-Safe | ❌ No (contains `+/=`) | ✅ Yes (uses `-_`) |\n| Padding | ✅ Yes (`=`) | ❌ No (removed) |\n| RFC 4648 Section 4 | ✅ Yes | ❌ No |\n| RFC 4648 Section 5 | ❌ No | ✅ Yes |\n| Use in URLs | ⚠️ Requires encoding | ✅ Direct use |\n| JWT Compatible | ❌ No | ✅ Yes |\n\n## Keywords\n\nbase64url, url-safe-encoding, base64-encoding, jwt, php-encoder, rfc-4648, url-encoding, api-tokens, zero-dependencies, php-library\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantikirra%2Fbase64url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantikirra%2Fbase64url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantikirra%2Fbase64url/lists"}