Last active
March 8, 2021 15:24
-
-
Save markvanwijnen/796a5c620e8c43e803347d8eb3936eaa 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
import CommonCrypto | |
extension String { | |
func hmacSHA1Hash(key: String) -> String { | |
var digest = [UInt8](repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH)) | |
CCHmac(CCHmacAlgorithm(kCCHmacAlgSHA1), | |
key, | |
key.count, | |
self, | |
self.count, | |
&digest) | |
return Data(digest).base64EncodedString() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment