https://github.com/spurreiter/base64-utf8-array
Base64 en- and decoding for Uint8Arrays
https://github.com/spurreiter/base64-utf8-array
base64 decoding encoding uint8array
Last synced: about 2 months ago
JSON representation
Base64 en- and decoding for Uint8Arrays
- Host: GitHub
- URL: https://github.com/spurreiter/base64-utf8-array
- Owner: spurreiter
- License: mit
- Created: 2019-04-27T21:23:33.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-07-13T08:16:44.000Z (over 1 year ago)
- Last Synced: 2025-09-28T14:27:03.804Z (6 months ago)
- Topics: base64, decoding, encoding, uint8array
- Language: JavaScript
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# base64-utf8-array
Base64 en- and decoding for Uint8Arrays.
Runs on node and browsers.
## Table of contents
* [Api](#api)
* [base64Decode](#base64decode)
* [base64Encode](#base64encode)
* [utf8ArrayToString](#utf8arraytostring)
* [stringToUtf8Array](#stringtoutf8array)
* [Installation](#installation)
* [Tests](#tests)
* [License](#license)
## Api
### base64Decode
decodes a base64 encoded string to an Uint8Array of UTF8 chars/values
#### Parameters
- `sBase64` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### Examples
```javascript
const { base64Decode, utf8ArrayToString } = require('base64-utf8-array')
const aUtf8 = base64Decode('YWJj')
const str = utf8ArrayToString(aUtf8)
//> str = 'abc'
```
Returns **[Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)**
### base64Encode
encodes a Uint8Array of UTF8 chars/values to a base64 encoded string
#### Parameters
- `arrUint8` **[Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)**
#### Examples
```javascript
const { stringToUtf8Array, base64Encode } = require('base64-utf8-array')
const aUtf8 = stringToUtf8Array('abc')
const sbase64 = base64Encode(aUtf8)
//> sbase64 = 'YWJj'
```
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
### utf8ArrayToString
converts a Uint8Array of UTF8 chars/values to a UTF16 string
#### Parameters
- `aUtf8`
- `Uint8Array`
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** UTF16 string
### stringToUtf8Array
converts a UTF16 string to a Uint8Array of UTF8 chars/values
#### Parameters
- `str` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** UTF16 string
Returns **[Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)**
## Installation
Requires [nodejs](http://nodejs.org/).
```sh
$ npm install --save base64-utf8-array
```
## Tests
```sh
$ npm test
```
## License
MIT licensed