websockets/bufferutil


WebSocket buffer utils

License: MIT

Language: C

Keywords: mask, utilities, websocket


bufferutil

Version npm Linux/macOS Build Windows Build

bufferutil is what makes ws fast. It provides some utilities to efficiently perform some operations such as masking and unmasking the data payload of WebSocket frames.

Installation

npm install bufferutil --save-optional

The --save-optional flag tells npm to save the package in your package.json under the optionalDependencies key.

API

The module exports two functions.

bufferUtil.mask(source, mask, output, offset, length)

Masks a buffer using the given masking-key as specified by the WebSocket protocol.

Arguments

  • source - The buffer to mask.
  • mask - A buffer representing the masking-key.
  • output - The buffer where to store the result.
  • offset - The offset at which to start writing.
  • length - The number of bytes to mask.

Example

'use strict';

const bufferUtil = require('bufferutil');
const crypto = require('crypto');

const source = crypto.randomBytes(10);
const mask = crypto.randomBytes(4);

bufferUtil.mask(source, mask, source, 0, source.length);

bufferUtil.unmask(buffer, mask)

Unmasks a buffer using the given masking-key as specified by the WebSocket protocol.

Arguments

  • buffer - The buffer to unmask.
  • mask - A buffer representing the masking-key.

Example

'use strict';

const bufferUtil = require('bufferutil');
const crypto = require('crypto');

const buffer = crypto.randomBytes(10);
const mask = crypto.randomBytes(4);

bufferUtil.unmask(buffer, mask);

License

MIT

Project Statistics

Sourcerank 17
Repository Size 50.8 KB
Stars 57
Forks 27
Watchers 15
Open issues 0
Dependencies 3
Contributors 12
Tags 23
Created
Last updated
Last pushed

Top Contributors See all

greenkeeper[bot] Luigi Pinca Arnout Kazemier Tom Atkinson Julián Duque Chris Ross Mick Killianey Antti Risteli James Ide PatrickJS Adam Brady

Packages Referencing this Repo

bufferutil
WebSocket buffer utils
Latest release 4.0.1 - Updated - 57 stars

Recent Tags See all

v4.0.1 December 23, 2018
v4.0.0 July 03, 2018
v3.0.5 May 05, 2018
v3.0.4 April 06, 2018
v3.0.3-napi December 04, 2017
v3.0.3 November 03, 2017
v3.0.2 July 07, 2017
v3.0.1 May 31, 2017
v3.0.0 March 03, 2017
v2.0.1 February 07, 2017
v2.0.0 February 03, 2017
2.0.0 February 03, 2017
v1.3.0 November 27, 2016
1.3.0 November 27, 2016
v1.2.1 August 21, 2015

Interesting Forks See all

telerik/bufferutil
WebSocket buffer util
C++ - Last pushed - 1 stars
mkillianey/bufferutil
WebSocket buffer util
This repository is no longer available - 1 stars
gdi2290/bufferutil
WebSocket buffer util
C++ - Last pushed - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2018-12-23 08:08:27 UTC

Login to resync this repository