increment-buffer
v1.0.1
Published
increment a buffer (with carry)
Downloads
537
Readme
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