1.0.1 • Published 8 years ago

increment-buffer v1.0.1

Weekly downloads
909
License
MIT
Repository
github
Last release
8 years ago

increment-buffer

increment a buffer (with carry)

Example

Useful for managing nonces when using libsodium In particular, see Notes section regarding reusing keys (scroll to bottom)

> var inc = require('increment-buffer')
> inc(new Buffer([0, 0, 0, 0]))
<Buffer 00 00 00 01>

> //with carry...
> inc(new Buffer([0, 0, 0, 255]))
<Buffer 00 00 01 00>

> //wrap around
> inc(new Buffer([255, 255, 255, 255]))
<Buffer 00 00 00 00>

License

MIT