Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Encoding Functions

base64encode

base64encode(<str>) - returns a Base64-encoded string

Decoding Functions

base64decode

base64decode(<str>) - returns a Base64-decoded string

Hashing Functions

hashFunctions

hashFunctions() - returns the array of supported hash function names (strings) supported by the current Node engine

hash

...

math:base64encode(str)

Given a utf8 string, str, return the base64 string 

math:base64decode(str)

Decode the given base64 string, str, return the utf8 string

math:hashAlgorithms

An array of hash algorithim names (string) 

Code Block
themeConfluence
langjavascript
 math:hashAlgorithms.klog() // ["sha256", "sha512", "DSA", ...]

math:hash(algorithm, str [, encoding])

Return the hash for the str using the given algorithm. Optionally specify the encoding "hex" (default) and "base64"

Code Block
themeConfluence
langjavascript
 math:hash("sha256", "hello") // "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
 math:hash("sha256", "hello", "base64") // "LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="

math:hmac(algorithm, key, message [, encoding])

Return an hmac string of message from the given hash algorithm and secret key. Optionally specify the encoding "hex" (default) and "base64"

Code Block
themeConfluence
langjavascript
 math:hmac("sha256", "a secret", "some message") // "86de43245b44531ac38b6a6a691996287d932a8dea03bc69b193b90caf48ff53"
 math:hmac("sha256", "a secret", "some message", "base64") // "ht5DJFtEUxrDi2pqaRmWKH2TKo3qA7xpsZO5DK9I/1M="


Info
titleEngine Compatibility

Everything after this note is not supported at this time.

...

Code Block
themeConfluence
langjavascript
       n = math:exp(2);

int

int(<num>) - the integer value of <num>

...

Code Block
themeConfluence
langjavascript
 
     g = math:rad2grad(r);

Digest functions

md5

Warning
titleSecurity

Based on the recommendations of NIST SP 800-131A, avoid MD5 where collision resistance is required, such as digital signatures.

md5(<str>) - calculate the hex string representing the 16 byte md5 digest of the argument string.

Code Block
themeConfluence
langjavascript
  d = math:md5("Hello" + foo)

sha1

Warning
titleSecurity

Based on the recommendations of NIST SP 800-131A, avoid SHA-1 where collision resistance is required, such as digital signatures.

sha1(<str>) - calculate the hex string representing the 20 byte SHA1 digest of the argument string.

Code Block
themeConfluence
langjavascript
  d = math:sha1("Hello" + foo)

hmac_sha1

hmac_sha1(<str>, <key>) - calculate the hmac signature of a string with a key, encoded as a binary string.

Code Block
themeConfluence
langjavascript
  sig = math:hmac_sha1("Hello" + foo, "mykey")

hmac_sha1_hex

hmac_sha1_hex(<str>, <key>) - calculate the hmac signature of a string with a key, encoded as a hex string.

Code Block
themeConfluence
langjavascript
  sig = math:hmac_sha1_hex("Hello" + foo, "mykey")

hmac_sha1_base64

hmac_sha1_base64(<str>, <key>) - calculate the hmac signature of a string with a key, encoded as base64.

Code Block
themeConfluence
langjavascript
  sig = math:hmac_sha1_base64("Hello" + foo, "mykey")

hmac_sha256

hmac_sha256(<str>, <key>) - calculate the hmac signature of a string with a key, encoded as a binary string.

Code Block
themeConfluence
langjavascript
  sig = math:hmac_sha256("Hello" + foo, "mykey")

hmac_sha256_hex

hmac_sha256_hex(<str>, <key>) - calculate the hmac signature of a string with a key, encoded as a hex string.

Code Block
themeConfluence
langjavascript
  sig = math:hmac_sha256_hex("Hello" + foo, "mykey")

hmac_sha256_base64

hmac_sha256_base64(<str>, <key>) - calculate the hmac signature of a string with a key, encoded as base64.

Code Block
themeConfluence
langjavascript
  sig = math:hmac_sha256_base64("Hello" + foo, "mykey")


Trigonometry

Trig functions expect radians as arguments unless otherwise noted

...