Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jedisct1/js-base64-ct
Safe Base64 encoding/decoding in pure JavaScript.
https://github.com/jedisct1/js-base64-ct
base64 constant-time javascript typescript
Last synced: about 2 months ago
JSON representation
Safe Base64 encoding/decoding in pure JavaScript.
- Host: GitHub
- URL: https://github.com/jedisct1/js-base64-ct
- Owner: jedisct1
- License: mit
- Created: 2021-07-10T13:10:17.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-07-10T13:20:34.000Z (over 3 years ago)
- Last Synced: 2024-10-10T12:52:51.067Z (2 months ago)
- Topics: base64, constant-time, javascript, typescript
- Language: TypeScript
- Homepage:
- Size: 6.84 KB
- Stars: 16
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Safe Base64 codecs for JavaScript
A pure JavaScript port of the libsodium base64 codecs.
Features:
* Supports traditional and URL-safe variants, with or without padding
* Rejects non-canonical padding
* Constant-time (best-effort), suitable for encoding/decoding secrets
* Characters can be ignored by the decoderAvailable on NPM: [base64-ct](https://www.npmjs.com/package/base64-ct)
Usage:
- Traditional alphabet, padding:
```js
const codec = new Base64(true);
const b64 = codec.encode(data);
const data2 = codec.decode(b64);
```- Traditional alphabet, no padding:
```js
const codec = new Base64(false);
const b64 = codec.encode(data);
const data2 = codec.decode(b64);
```- URL-safe, no padding:
```js
const codec = new Base64UrlSafe(false);
const b64 = codec.encode(data);
const data2 = codec.decode(b64);
```- URL-safe, padding, ignoring spaces and `\n`:
```js
const codec = new Base64UrlSafe(true, " \n");
const b64 = codec.encode(data);
const data2 = codec.decode(b64);
```