Menu

class: Digest

[177:14] (extern: com.lehman.aussomserver.connectors.AussomDigest) extends: object

Streaming digest object backed by java.security.MessageDigest. Use this when input arrives in chunks; for one-shot digests prefer the static codec helpers. After digest() the underlying state resets so the same object can be reused.

Methods

  • Digest (string Algorithm)

    Constructs a new Digest object for the given algorithm.

    • @p Algorithm is a string with the algorithm name. Accepts "MD5", "SHA-1", "SHA-256", "SHA-384", "SHA-512", and the unhyphenated forms.
    • @r This Digest object.
  • newDigest (string Algorithm)

  • update (Data)

    Feeds a chunk of data into the digest.

    • @p Data is a string (UTF-8) or Buffer to feed.
    • @r This Digest object.
  • updateFile (string Path)

    Feeds the bytes of a file into the digest, streamed in 8 KiB chunks.

    • @p Path is a string with the file path.
    • @r This Digest object.
  • digest ()

    Finalizes and returns the raw digest as a Buffer. After this call the underlying state is reset and the object is ready for fresh update calls.

    • @r A Buffer with the raw digest bytes.
  • reset ()

    Discards accumulated state without producing a digest.

    • @r This Digest object.
  • getAlgorithm ()

    Returns the resolved JCE algorithm name as a string.

    • @r A string with the algorithm name.

class: Hmac

[231:14] (extern: com.lehman.aussomserver.connectors.AussomHmac) extends: object

Streaming HMAC object backed by javax.crypto.Mac. The key is supplied to the constructor and retained, so digest() can be called repeatedly under the same key on fresh data.

Methods

  • Hmac (string Algorithm, Key)

    Constructs a new Hmac object for the given algorithm and key.

    • @p Algorithm is a string with the algorithm name. Accepts "SHA-1", "SHA-256", "SHA-384", "SHA-512", "HmacSHA256", etc.
    • @p Key is a string (UTF-8) or Buffer with the shared secret.
    • @r This Hmac object.
  • newHmac (string Algorithm, Key)

  • update (Data)

    Feeds a chunk of data into the MAC.

    • @p Data is a string (UTF-8) or Buffer to feed.
    • @r This Hmac object.
  • updateFile (string Path)

    Feeds the bytes of a file into the MAC, streamed in 8 KiB chunks.

    • @p Path is a string with the file path.
    • @r This Hmac object.
  • digest ()

    Finalizes and returns the raw HMAC tag as a Buffer. After this call the MAC is reset and ready for fresh update calls under the same key.

    • @r A Buffer with the raw HMAC tag bytes.
  • reset ()

    Discards accumulated state without producing a tag.

    • @r This Hmac object.
  • getAlgorithm ()

    Returns the resolved JCE algorithm name as a string.

    • @r A string with the algorithm name.

class: codec

[25:21] static (extern: com.lehman.aussomserver.connectors.AussomCodec) extends: object

The static codec class provides one-shot SHA / MD5 digest and HMAC-SHA functions over strings, Buffer payloads, and files. Digests are returned as raw Buffer objects; pipe through hex.encode(...) or base64.encode(...) for text output. For chunked input use the Digest and Hmac extern classes.

Methods

  • sha1 (Data)

    Computes the SHA-1 digest of the provided data.

    • @p Data is a string (UTF-8) or Buffer to digest.
    • @r A Buffer with the raw digest bytes.
  • sha256 (Data)

    Computes the SHA-256 digest of the provided data.

    • @p Data is a string (UTF-8) or Buffer to digest.
    • @r A Buffer with the raw digest bytes.
  • sha384 (Data)

    Computes the SHA-384 digest of the provided data.

    • @p Data is a string (UTF-8) or Buffer to digest.
    • @r A Buffer with the raw digest bytes.
  • sha512 (Data)

    Computes the SHA-512 digest of the provided data.

    • @p Data is a string (UTF-8) or Buffer to digest.
    • @r A Buffer with the raw digest bytes.
  • md5 (Data)

    Computes the MD5 digest of the provided data. MD5 is for legacy interop only; do not use it for signing.

    • @p Data is a string (UTF-8) or Buffer to digest.
    • @r A Buffer with the raw digest bytes.
  • sha1File (string Path)

    Computes the SHA-1 digest of a file, streamed.

    • @p Path is a string with the file path.
    • @r A Buffer with the raw digest bytes.
  • sha256File (string Path)

    Computes the SHA-256 digest of a file, streamed.

    • @p Path is a string with the file path.
    • @r A Buffer with the raw digest bytes.
  • sha384File (string Path)

    Computes the SHA-384 digest of a file, streamed.

    • @p Path is a string with the file path.
    • @r A Buffer with the raw digest bytes.
  • sha512File (string Path)

    Computes the SHA-512 digest of a file, streamed.

    • @p Path is a string with the file path.
    • @r A Buffer with the raw digest bytes.
  • md5File (string Path)

    Computes the MD5 digest of a file, streamed. MD5 is for legacy interop only; do not use it for signing.

    • @p Path is a string with the file path.
    • @r A Buffer with the raw digest bytes.
  • hmacSha1 (Data, Key)

    Computes the HMAC-SHA1 tag of the provided data under the provided key.

    • @p Data is a string (UTF-8) or Buffer to authenticate.
    • @p Key is a string (UTF-8) or Buffer with the shared secret.
    • @r A Buffer with the raw HMAC tag bytes.
  • hmacSha256 (Data, Key)

    Computes the HMAC-SHA256 tag of the provided data under the provided key.

    • @p Data is a string (UTF-8) or Buffer to authenticate.
    • @p Key is a string (UTF-8) or Buffer with the shared secret.
    • @r A Buffer with the raw HMAC tag bytes.
  • hmacSha384 (Data, Key)

    Computes the HMAC-SHA384 tag of the provided data under the provided key.

    • @p Data is a string (UTF-8) or Buffer to authenticate.
    • @p Key is a string (UTF-8) or Buffer with the shared secret.
    • @r A Buffer with the raw HMAC tag bytes.
  • hmacSha512 (Data, Key)

    Computes the HMAC-SHA512 tag of the provided data under the provided key.

    • @p Data is a string (UTF-8) or Buffer to authenticate.
    • @p Key is a string (UTF-8) or Buffer with the shared secret.
    • @r A Buffer with the raw HMAC tag bytes.
  • hmacSha1File (string Path, Key)

    Computes the HMAC-SHA1 tag of a file under the provided key, streamed.

    • @p Path is a string with the file path.
    • @p Key is a string (UTF-8) or Buffer with the shared secret.
    • @r A Buffer with the raw HMAC tag bytes.
  • hmacSha256File (string Path, Key)

    Computes the HMAC-SHA256 tag of a file under the provided key, streamed.

    • @p Path is a string with the file path.
    • @p Key is a string (UTF-8) or Buffer with the shared secret.
    • @r A Buffer with the raw HMAC tag bytes.
  • hmacSha384File (string Path, Key)

    Computes the HMAC-SHA384 tag of a file under the provided key, streamed.

    • @p Path is a string with the file path.
    • @p Key is a string (UTF-8) or Buffer with the shared secret.
    • @r A Buffer with the raw HMAC tag bytes.
  • hmacSha512File (string Path, Key)

    Computes the HMAC-SHA512 tag of a file under the provided key, streamed.

    • @p Path is a string with the file path.
    • @p Key is a string (UTF-8) or Buffer with the shared secret.
    • @r A Buffer with the raw HMAC tag bytes.