http://zorba.io/modules/hmac

View as XML or JSON.

This module provides functions that perform HMAC (hash-based message authentication code) operations. For example, they calculate message codes involving hash functions such as MD5 and various SHA variants. The result is the base64 encoded value of the hash. A hash may be used to verify the data integrity and the authenticity of a message.

Function Summary

compute-binary ($message as xs:base64Binary, $secret-key as xs:string, $hash-algo as xs:string) as xs:base64Binary external

Calculate the HMAC for the given message and secret-key involving an custom hash function.

compute ($message as xs:string, $secret-key as xs:string, $alg as xs:string) as xs:base64Binary external

Calculate the HMAC for the given message and secret-key involving an custom hash function.

md5-binary ($message as xs:base64Binary, $secret-key as xs:string) as xs:base64Binary

Calculate the HMAC for the given message and secret-key involving the MD5 hash function.

md5 ($message as xs:string, $secret-key as xs:string) as xs:base64Binary

Calculate the HMAC for the given message and secret-key involving the MD5 hash function.

sha1-binary ($message as xs:base64Binary, $secret-key as xs:string) as xs:base64Binary

Calculate the HMAC for the given message and secret-key involving the SHA1 hash function.

sha1 ($message as xs:string, $secret-key as xs:string) as xs:base64Binary

Calculate the HMAC for the given message and secret-key involving the SHA1 hash function.

Functions

compute-binary#3

declare  function hmac:compute-binary($message as xs:base64Binary, $secret-key as xs:string, $hash-algo as xs:string) as xs:base64Binary external
Calculate the HMAC for the given message and secret-key involving an custom hash function. Before calculating the code, the given base64-encoded message is base64-decoded.

Parameters

message as xs:base64Binary
the message to be authenticated
secret-key as xs:string
the secret key used for calculating the authentication
hash-algo as xs:string

Returns

xs:base64Binary
the base64 encoded message authentication code

compute#3

declare  function hmac:compute($message as xs:string, $secret-key as xs:string, $alg as xs:string) as xs:base64Binary external
Calculate the HMAC for the given message and secret-key involving an custom hash function.

Parameters

message as xs:string
the message to be authenticated
secret-key as xs:string
the secret key used for calculating the authentication
alg as xs:string
The algorithm to use for the hashing operation. Supported algorithms are "md5", "sha1", and "sha256".

Returns

xs:base64Binary
the base64 encoded message authentication code

md5-binary#2

declare  function hmac:md5-binary($message as xs:base64Binary, $secret-key as xs:string) as xs:base64Binary
Calculate the HMAC for the given message and secret-key involving the MD5 hash function. Before calculating the code, the given base64-encoded message is base64-decoded.

Parameters

message as xs:base64Binary
the message to be authenticated
secret-key as xs:string
the secret key used for calculating the authentication

Returns

xs:base64Binary
the base64 encoded message authentication code

md5#2

declare  function hmac:md5($message as xs:string, $secret-key as xs:string) as xs:base64Binary
Calculate the HMAC for the given message and secret-key involving the MD5 hash function.

Parameters

message as xs:string
the message to be authenticated
secret-key as xs:string
the secret key used for calculating the authentication

Returns

xs:base64Binary
the base64 encoded message authentication code

sha1-binary#2

declare  function hmac:sha1-binary($message as xs:base64Binary, $secret-key as xs:string) as xs:base64Binary
Calculate the HMAC for the given message and secret-key involving the SHA1 hash function. Before calculating the code, the given base64-encoded message is base64-decoded.

Parameters

message as xs:base64Binary
the message to be authenticated
secret-key as xs:string
the secret key used for calculating the authentication

Returns

xs:base64Binary
the base64 encoded message authentication code

sha1#2

declare  function hmac:sha1($message as xs:string, $secret-key as xs:string) as xs:base64Binary
Calculate the HMAC for the given message and secret-key involving the SHA1 hash function.

Parameters

message as xs:string
the message to be authenticated
secret-key as xs:string
the secret key used for calculating the authentication

Returns

xs:base64Binary
the base64 encoded message authentication code