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

SHA

Constants

Buffer lengths (integer)

  • crypto_hash_BYTES
  • crypto_hash_sha256_BYTES
  • crypto_hash_sha512_BYTES
  • crypto_hash_sha512_STATEBYTES

String constants (string)

  • crypto_hash_PRIMITIVE

crypto_hash

sodium-native

sodium.crypto_hash_(out, in)

Hashes a value to a short hash based on a key.

  • out should be a buffer of length crypto_hash_BYTES
  • in should be a buffer of any size

The generated short hash is stored in out.


crypto_hash_sha256

sodium-native

sodium.crypto_hash_sha256(out, in)

Hashes a value to a short hash based on a key.

  • out should be a buffer of length crypto_hash_sha256_BYTES
  • in should be a buffer of any size

The generated short hash is stored in out.


Stateful API

crypto_hash_sha256_instance

sodium-native

var instance = sodium.crypto_hash_sha256_instance()

Creates an instance that has stream of input data to sha256.

instance.update

instance.update(in)

Updates the instance with a new piece of data.

  • in should be a buffer of any size

instance.final

instance.final(out)

Finalizes the instance.

  • out should be a buffer of length crypto_hash_sha256_BYTES

The generated hash is stored in out.


crypto_hash_sha512

sodium-native

sodium.crypto_hash_sha512(out, in)

Hashes a value to a short hash based on a key.

  • out should be a buffer of length crypto_hash_sha512_BYTES
  • in should be a buffer of any size

The generated short hash is stored in out.


crypto_hash_sha512_instance

sodium-native

var instance = sodium.crypto_hash_sha512_instance()

Creates an instance that has stream of input data to sha512.

instance.update

instance.update(in)

Updates the instance with a new piece of data.

  • in should be a buffer of any size

instance.final

instance.final(out)

Finalizes the instance.

  • out should be a buffer of length crypto_hash_sha512_BYTES

The generated hash is stored in out.

Stateful API

Replaces the above instance implementation in the N-API release

crypto_hash_sha256_init

sodium-native

var state = Buffer.alloc(crypto_hash_sha256_STATEBYTES)

sodium.crypto_hash_sha256_init(state, [key], outlen)

Initialise a new hash state.

  • state must be a buffer of length crypto_hash_sha256_STATEBYTES bytes

crypto_hash_sha256_update

sodium-native

sodium.crypto_hash_sha256_update(state, in)

Update a hash state with a given input.

  • state must be a buffer of length crypto_hash_sha256_STATEBYTES bytes
  • in should be a a buffer of any length

crypto_hash_sha256_final(state, out)

sodium-native

sodium.crypto_hash_sha256_final(state, out)

Finalize a given hash state and write the digest to out buffer.

  • state must be a buffer of length crypto_hash_sha256_STATEBYTES bytes
  • out must be a buffer of byte length crypto_hash_sha256_BYTES bytes

crypto_hash_sha512_init

sodium-native

var state = Buffer.alloc(crypto_hash_sha512_STATEBYTES)

sodium.crypto_hash_sha512_init(state, [key], outlen)

Initialise a new hash state.

  • state must be a buffer of length crypto_hash_sha512_STATEBYTES bytes

crypto_hash_sha512_update

sodium-native

sodium.crypto_hash_sha512_update(state, in)

Update a hash state with a given input.

  • state must be a buffer of length crypto_hash_sha512_STATEBYTES bytes
  • in should be a a buffer of any length

crypto_hash_sha512_final(state, out)

sodium-native

sodium.crypto_hash_sha512_final(state, out)

Finalize a given hash state and write the digest to out buffer.

  • state must be a buffer of length crypto_hash_sha512_STATEBYTES bytes
  • out must be a buffer of byte length crypto_hash_sha512_BYTES bytes
← Key DerivationLicense →
  • Constants
  • crypto_hash
  • crypto_hash_sha256
  • Stateful API
  • crypto_hash_sha256_instance
  • instance.update
  • instance.final
  • crypto_hash_sha512
  • crypto_hash_sha512_instance
  • instance.update
  • instance.final
  • Stateful API
  • crypto_hash_sha256_init
  • crypto_hash_sha256_update
  • crypto_hash_sha256_final(state, out)
  • crypto_hash_sha512_init
  • crypto_hash_sha512_update
  • crypto_hash_sha512_final(state, out)
Docs
Get StartedAPI
Community
LibsodiumHyperdivisionHyperdivision on Twitter
More
GitHubStar
Copyright © 2020 Hyperdivision