How can I compute the SHA512/256 hash in Swift?

555 views Asked by At

I'm familiar with CryptoKit and the SHA512 implementation, which is super easy to use.

let digest = SHA512.hash(data: Data("".utf8))

However, I can't seem to find how to compute SHA512/256 (the truncated version of SHA512) anywhere in the Apple CryptoKit documentation. Do I somehow have to combine SHA512 with SHA256Digest?

1

There are 1 answers

2
Mostafa Shamin Yeasar On

I think this pod will do the trick.

This has the implementation for SHA512/SHA256. (Check readme's HASH section: SHA-2)

Link: SHA512/SHA256 Lead