Created
December 13, 2023 11:42
-
-
Save Ljzn/a491111df7826276fe8f40028c6014d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def okx_signing(config, %{url: url, body: body, method: method}) do | |
secret = config["okx_secret_key"] | |
access_key = "your access key" | |
timestamp = DateTime.utc_now() |> DateTime.truncate(:millisecond) |> DateTime.to_iso8601() | |
%{path: path, query: query} = URI.new!(url) | |
data = timestamp <> method <> path <> "?" <> query <> body | |
sign = :crypto.mac(:hmac, :sha256, secret, data) |> Base.encode64() | |
[ | |
{"OK-ACCESS-KEY", access_key}, | |
{"OK-ACCESS-TIMESTAMP", timestamp}, | |
{"OK-ACCESS-PASSPHRASE", "your passphrase"}, | |
{"OK-ACCESS-SIGN", sign} | |
] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment