I basically am trying to take a String and do what would look like this in php:
$signature= base64_encode(hash_hmac('sha1', $data, $secretKey, true));
However, do it in Swift... I see a lot of posts about other people trying to do things with CommonCrypto, but that module doesn't seem to install.
So 3 questions really:
- Is CommonCrypto the correct way to do this?
- If so, how do I add the framework?
- If CommonCrypto isn't the best way to do this, what is?
My current code looks like this:
var authString:String = "PUT\nTEST=BLAH\nTEST2=BLAHBLAHBLAH"
let hmacResult:String = authString.sha1()
...
extension String {
func sha1() -> String {
//Do Something...
}
}