https://github.com/exodusmovement/buffer-noise
Expand a buffer to a specified length.
https://github.com/exodusmovement/buffer-noise
Last synced: 3 months ago
JSON representation
Expand a buffer to a specified length.
- Host: GitHub
- URL: https://github.com/exodusmovement/buffer-noise
- Owner: ExodusMovement
- License: mit
- Created: 2017-04-05T20:20:49.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-12T23:00:11.000Z (about 2 years ago)
- Last Synced: 2024-04-14T13:10:04.025Z (about 1 year ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 1
- Watchers: 31
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# buffer-noise
[](https://npmjs.com/package/buffer-noise)
[](https://github.com/ExodusMovement/buffer-noise/actions/workflows/ci.yml?query=branch%3Amaster)Expand a buffer to a specified length. If the buffer is smaller than the specified length, the remaining space is filled with random bytes. A 32-bit Unsigned Big-Endian Integer containing the length of the data is always prepended to the buffer.
This module can be used for obfuscating an encrypted file's size for plausible deniability.
## Installation
npm install buffer-noise
## Usage
```js
const size = 25
const { expand, shrink } = require('buffer-noise')(size)const data = Buffer.from('Hello World!')
const newData = expand(data)
console.log(data, newData)
// Prints:
//
//
assert(newData.length === size)
assert(shrink(newData).equals(data))
```## License
MIT