json_web_token v0.2.10 JsonWebToken.Util

Utility functions

Link to this section Summary

Functions

Predicate that compares two strings for equality in constant-time to avoid timing attacks

Return the parameter passed in, unless it is nil or an empty string

Link to this section Functions

Link to this function constant_time_compare?(a, b)

Predicate that compares two strings for equality in constant-time to avoid timing attacks

Example

iex> JsonWebToken.Util.constant_time_compare?("a", "A")
false

see: https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40#section-3.2

Link to this function validate_present(param)

Return the parameter passed in, unless it is nil or an empty string

Example

iex> JsonWebToken.Util.validate_present("a")
"a"