2
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

Organization

swiftでHMAC SHA256署名

クライアントだけでSHA256署名する方法に少しつまったのでメモ
仮想通貨の取引所のAPIを叩く際に必要なことが多いようなので誰かに役に立てれば。。

実装

こちらのライブラリを使用
CryptoSwift

cocoapodsで恒例のインストール

pod 'CryptoSwift'

以下のように使用

var bytes: [UInt8] = []

bytes += "署名したい文字列".bytes

let signedString = try? HMAC(key: "署名したいキー", variant: .sha256).authenticate(bytes)

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
2
Help us understand the problem. What are the problem?