WechatPay.Utils.Signature (WechatPay v0.10.0) View Source

Module to sign data

Link to this section Summary

Functions

Generate the signature of data with API key

Verify the signature of Wechat's response

Link to this section Functions

Link to this function

sign(data, api_key, arg3)

View Source

Specs

sign(map(), String.t(), :md5 | :sha256) :: String.t()

Generate the signature of data with API key

Example

iex> WechatPay.Utils.Signature.sign(%{...}, "wx9999")
...> "02696FC7E3E19F852A0335F2F007DD3E"
Link to this function

verify(data, api_key, sign_type)

View Source

Specs

verify(map(), String.t(), :md5 | :sha256) :: :ok | {:error, WechatPay.Error.t()}

Verify the signature of Wechat's response

Example

iex > WechatPay.Utils.Signature.verify(%{sign: "foobar"}, "a45a313dfbf0494288c3e56bcacf30daa")
... > :ok