10
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Swift ハッシュ関数 SHA-256

Posted at

ハッシュ関数 SHA-256

Secure Hash Algorithm 256 bit 入力データサイズに関わらず256ビットのハッシュ値を生成。 NIST(National Insitute of Standards and Technology)(アメリカ国立標準技術研究所)で標準化。

コード

Example

import CryptoKit

var hello = "hello"
var data = hello.data(using: .utf8)

print(SHA256.hash(data: data!))

結果

SHA256 digest: 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

memo

  • Document
  • 対応:iOS 13+、macOS 10.15+
  • SHA512、SHA384もある
10
5
1

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
10
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?