LoginSignup
2

More than 5 years have passed since last update.

swiftでHMAC SHA256署名

Last updated at Posted at 2018-05-25

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

実装

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

cocoapodsで恒例のインストール

pod 'CryptoSwift'

以下のように使用

var bytes: [UInt8] = []

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

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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2