title: Using Swift, how can I create an OpenSSL HMAC digest using SHA1 and then encode with strict encode64
body: <p>I need to create a Base64 strict encoded representation of an OpenSSL HMAC digest using SHA1. I have the code in <code>Ruby</code>, but I need the similar code in <code>Swift</code>. Does anybody have that easy?</p>
  
  <p>The code in <code>Ruby</code> is:</p>
  
  <pre><code>digest = OpenSSL::Digest.new('sha1')
  hmac_digest = OpenSSL::HMAC.digest(digest, secret_key, canonical_string)
  Base64.strict_encode64(hmac_digest)
  </code></pre>
  
  <p>As you see above, my inputs are 2 strings (<code>secret_key</code> and <code>canonical_string</code>) and I first create the digest and then I encode it.</p>
  
  <p>So, what would be the correct code in <code>Swift</code> that will give the same result for the same inputs?</p>