Padding
Bindings for the padding API. See the libsodium padding docs for more information.
sodium_pad
var paddedLength = sodium.sodium_pad(buf, unpaddedLength, blocksize)
Pads buf
with random data from index unpaddedLength
up to closest multiple of blocksize
.
buf
must be abuffer
unpaddedLength
must be an integer at mostbuf.length
blocksize
must be an integer greater than 1, but at mostbuf.length
Returns the length of the padded data (so you may .slice
the buffer
to here).
sodium_unpad
var unpaddedLength = sodium.sodium_unpad(buf, paddedLength, blocksize)
Calculates unpaddedLength
from a padded buf
with blocksize
.
buf
must be abuffer
paddedLength
must be an integer at mostbuf.length
blocksize
must be an integer greater than 1, but at mostbuf.length
Returns the length of the unpadded data (so you may .slice
the buffer
to here).