$ npm install increment-buffer
increment a buffer (with carry)
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>
MIT
© 2010 - cnpmjs.org x YWFE | Home | YWFE