$ gnpm 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
Copyright 2013 - present © cnpmjs.org | Home |