https://github.com/fabiospampinato/radix64url-encoding
Radix64url encoding, a.k.a. Base64url encoding. An extremely fast and synchronous JS implementation.
https://github.com/fabiospampinato/radix64url-encoding
base64url encoding fast radix64url
Last synced: 11 months ago
JSON representation
Radix64url encoding, a.k.a. Base64url encoding. An extremely fast and synchronous JS implementation.
- Host: GitHub
- URL: https://github.com/fabiospampinato/radix64url-encoding
- Owner: fabiospampinato
- License: mit
- Created: 2023-01-12T22:40:49.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-09-24T16:28:50.000Z (over 2 years ago)
- Last Synced: 2024-11-19T19:56:15.193Z (over 1 year ago)
- Topics: base64url, encoding, fast, radix64url
- Language: TypeScript
- Homepage:
- Size: 5.86 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Radix64url Encoding
Radix64url encoding, a.k.a. Base64url encoding. An extremely fast and synchronous JS implementation.
## Install
```sh
npm install radix64url-encoding
```
## Usage
```ts
import Radix64url from 'radix64url-encoding';
// Uint8Array encoding & decoding
{
const raw = 'Hello 😃';
const uint8 = new TextEncoder ().encode ( raw );
console.log ( uint8 ); // => Uint8Array(10) [ 72, 101, 108, 108, 111, 32, 240, 159, 152, 131 ]
const encoded = Radix64url.encode ( uint8 );
console.log ( encoded ); // => 'SGVsbG8g8J-Ygw'
const decoded = Radix64url.decodeStr ( encoded );
console.log ( decoded ); // => Uint8Array(10) [ 72, 101, 108, 108, 111, 32, 240, 159, 152, 131 ]
}
// String encoding & decoding
{
const raw = 'Hello 😃';
const encoded = Radix64url.encodeStr ( raw );
console.log ( encoded ); // => 'SGVsbG8g8J-Ygw'
const decoded = Radix64url.decodeStr ( encoded );
console.log ( decoded ); // => 'Hello 😃'
}
// Check if a string is radix64url-encoded
{
console.log ( Radix64url.is ( 'SGVsbG8g8J-Ygw' ) ); // => true
console.log ( Radix64url.is ( '😃' ) ); // => false
}
```
## License
MIT © Fabio Spampinato