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

Helpers

Bindings for various helper functions. See the libsodium helpers docs for more information.


sodium_memcmp

sodium-native

var bool = sodium.sodium_memcmp(b1, b2)

Compares b1 with b2, in constant-time for b1.length.

  • b1 must be a buffer
  • b2 must be a buffer and must be b1.length bytes

Returns true when equal, otherwise false.


sodium_compare

sodium-native

var direction = sodium.sodium_compare(b1, b2)

Compares b1 with b2, regarding either as little-endian encoded number.

  • b1 must be a buffer
  • b2 must be a buffer and must be b1.length bytes

Returns 1, 0, or -1 on whether b1 is greater than, equal to, or less than b2. This is the same scheme as Array.prototype.sort expect.


sodium_add

sodium-native

sodium.sodium_add(a, b)

Adds b to a (wrapping), regarding either as little-endian encoded number, and writing the result into a.

  • a must be a buffer
  • b must be a buffer and must be a.length bytes

sodium_sub

sodium-native

sodium.sodium_sub(a, b)

Subtracts b from a (wrapping), regarding either as little-endian encoded number, and writing the result into a.

  • a must be a buffer
  • b must be a buffer and must be a.length bytes

sodium_increment

sodium-native

sodium.sodium_increment(buf)

Increments buf as a little-endian number. This operation is constant-time for the length of buf.

  • buf must be a buffer

sodium_is_zero

sodium-native

var bool = sodium.sodium_is_zero(buf, len)

Tests whether buf is all zero for len bytes. This operation is constant-time for len.

  • len must be an integer at most buf.length

Returns true if all len bytes are zero, otherwise false.

← Generating Random DataPadding →
  • sodium_memcmp
  • sodium_compare
  • sodium_add
  • sodium_sub
  • sodium_increment
  • sodium_is_zero
Docs
Get StartedAPI
Community
LibsodiumHyperdivisionHyperdivision on Twitter
More
GitHubStar
Copyright © 2020 Hyperdivision