# b64

> Base64 streaming encoder and decoder

Latest version **4.1.2** (published 2018-11-03) · BSD-3-Clause license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install b64
pnpm add b64
yarn add b64
bun add b64
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.1.2 |
| Published | 2018-11-03 |
| First published | 2011-08-04 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 40 |
| Maintainers | hueniverse, wyatt |
| Keywords | buffer, base64, decode, encode, stream |

## Links

- npm: https://www.npmjs.com/package/b64
- Repository: https://github.com/hapijs/b64
- Homepage: https://github.com/hapijs/b64#readme
- Issues: https://github.com/hapijs/b64/issues
- npm.io page: https://npm.io/package/b64

## Dependencies (1)

- [hoek](https://npm.io/package/hoek.md) 6.x.x

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 4.1.2 (latest) — 2018-11-03
- 3.1.1 (v3-legacy) — 2024-01-06
- 4.1.1 — 2018-11-01
- 4.1.0 — 2018-10-31
- 4.0.0 — 2017-09-26
- 3.0.3 — 2017-07-31
- 3.0.2 — 2016-07-28
- 3.0.1 — 2016-05-19
- 3.0.0 — 2015-10-31
- 2.0.1 — 2015-06-28
- 2.0.0 — 2014-09-28
- 1.0.1 — 2011-11-19
- 1.0.0 — 2011-08-04

## README

Base64 streaming encoder and decoder

[![Build Status](https://secure.travis-ci.org/hapijs/b64.png)](http://travis-ci.org/hapijs/b64)

Lead Maintainer - [Wyatt Preul](https://github.com/geek)


## Installation

```sh
npm install b64 --save
```


## API

### encode(buffer)

Base64 encode the buffer and return it as a new Buffer.


### decode(buffer)

Base64 decode the buffer and return the result as a new buffer.


### Encoder

Transform stream that base64 encodes each chunk of the stream.

Example:

```js
'use strict';

const Fs = require('fs');
const B64 = require('b64');

const stream = Fs.createReadStream(`${__dirname}/package.json`);
const encoder = new B64.Encoder();

stream.pipe(encoder).pipe(process.stdout);
```


### Decoder

Transform stream that base64 decodes each chunk of the stream.

Example:

```js
'use strict';

const Fs = require('fs');
const B64 = require('b64');

const stream = Fs.createReadStream(`${__dirname}/encodedfile.b64`);
const decoder = new B64.Decoder();

stream.pipe(decoder).pipe(process.stdout);
```

### base64urlEncode(value)

Encodes value of string or buffer type in Base64 or URL encoding, function will assert input value is correct.

### base64urlDecode(value)

Decodes string into Base64 or URL encoding, function throws an error on invalid input and returns a string or buffer depending on encoding provided.  Default encoding is binary.

---
_Source: https://npm.io/package/b64 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
