sodium-native

sodium-native

  • Get Started
  • API
  • Github

›API

Get Started

  • Introduction
  • Projects using sodium-native

API

  • Compatibility
  • API
  • Memory Protection
  • Generating Random Data
  • Helpers
  • Padding
  • Signing
  • Generic Hashing
  • Public/Secret Key Box Encryption
  • Sealed Box Encryption
  • Secret Key Box Encryption
  • AEAD (Authenticated Encryption with Additional Data)
  • Non-Authenticated Streaming Encryption
  • Authentication
  • Stream Encryption
  • One-Time Authentication
  • Password Hashing
  • Key Exchange
  • Diffie-Hellman
  • Finite Field Arithmetic
  • Short Hashes
  • Key Derivation
  • SHA
  • License

Padding

Bindings for the padding API. See the libsodium padding docs for more information.


sodium_pad

sodium-native

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 a buffer
  • unpaddedLength must be an integer at most buf.length
  • blocksize must be an integer greater than 1, but at most buf.length

Returns the length of the padded data (so you may .slice the buffer to here).


sodium_unpad

sodium-native

var unpaddedLength = sodium.sodium_unpad(buf, paddedLength, blocksize)

Calculates unpaddedLength from a padded buf with blocksize.

  • buf must be a buffer
  • paddedLength must be an integer at most buf.length
  • blocksize must be an integer greater than 1, but at most buf.length

Returns the length of the unpadded data (so you may .slice the buffer to here).

← HelpersSigning →
  • sodium_pad
  • sodium_unpad
Docs
Get StartedAPI
Community
LibsodiumHyperdivisionHyperdivision on Twitter
More
GitHubStar
Copyright © 2020 Hyperdivision