Wednesday, 15 February 2012

How to do HMAC-SHA1 in swift -


I am trying to basically take a string and do what I see in php:

  $ sign = base64_encode (hash_hammak ('sha1', $ data, $ secret, true));  

However, do this in swift ... I look at many posts about other people who are trying to work with normal action , But that module does not seem to be installed.

So the 3 questions really are:

  1. Is there a correct way to do this, Common Criteria?
  2. If so, how do I add a framework?
  3. If CommonCrypto is not the best way to do this, what is it?

My current code looks like this:

  var authString: String = "PUT \ nTEST = BLAH \ nTEST2 = BLAHBLAHBLAH "hmacResult: string = authString.sha1 () ... extension string {func sha1 () - & gt; String {// Do Something ...}}  


No comments:

Post a Comment