How to do HMAC-SHA1 in swift -


i trying take string , in php:

    $signature= base64_encode(hash_hmac('sha1', $data, $secretkey, true)); 

however, in swift... see lot of posts other people trying things commoncrypto, module doesn't seem install.

so 3 questions really:

  1. is commoncrypto correct way this?
  2. if so, how add framework?
  3. if commoncrypto isn't best way this, is?

my current code looks this:

    var authstring:string = "put\ntest=blah\ntest2=blahblahblah"     let hmacresult:string = authstring.sha1()      ...      extension string {         func sha1() -> string {           //do something...         }     } 


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -