title: Amazon Signature Creation
body: <p>I am trying to implement itemLookup inside of my app from Amazon's API. I've seen documentation for earlier versions of Swift, but they don't seem to work anymore, but I have it working to a point.</p>
  
  <p>I ported the code from Javascript as described in <a href="https://stackoverflow.com/questions/22587599/how-to-properly-sign-a-get-request-to-amazons-itemlookup-using-client-side-java">this post</a></p>
  
  <p>This is what I have so far:</p>
  
  <pre><code> func callAmazon(){
  
          let amazonAccessID = "XXXXXX"
          let secretKey = "XXXXXXXXX"
          let associateTag = "XXXXX"
  
          var parameters = [String]();
  
          let timestamp = ISO8601FormatStringFromDate(NSDate())
  
          parameters.append("AWSAccessKeyId=" + amazonAccessID);
          parameters.append("Keywords=" + "boots");
          parameters.append("Operation=ItemSearch");
          parameters.append("Service=AWSECommerceService");
          parameters.append("Timestamp=" + (timestamp as String));
          parameters.append("Version=2013-08-01");
          parameters.append("AssociateTag=" + associateTag);
  
          parameters.sortInPlace {$0 &lt; $1}
          let paramString = parameters.joinWithSeparator("&amp;")
  
          let method = NSMutableURLRequest().HTTPMethod
  
          let signingKey = "\(method)\n" + "webservices.amazon.com\n" + "/onca/xml\n" + paramString
  
          let signature = sha256(signingKey, secretKey: secretKey)
  
          let finalString = signature.encodeURIComponent()
  
          let amazonUrl =  "http://webservices.amazon.com/onca/xml?" + paramString + "&amp;Signature=" + finalString!
  
          print("AmazonURL!!! : ", amazonUrl)
  
  
      Alamofire.request(.GET, amazonUrl, parameters: nil).response {
          (request, response, data, error) in
              let xml = SHXMLParser().parseData(data!)
              print(xml)// output the FilmID element.
      }
  
  
  }
  
  func sha256(StringToSign : String, secretKey : String) -&gt; String{
  
      var hex = StringToSign.hmac(.SHA256, key: secretKey)
      let hexData = hex.dataUsingEncoding(NSUTF8StringEncoding)
      let finalString = hexData?.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)
  
      return finalString!
  
  }
  </code></pre>
  
  <p>And this is the output.</p>
  
  <pre><code> [ItemSearchErrorResponse: {
  Error =     {
      Code = SignatureDoesNotMatch;
      Message = "The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.";
  };
  RequestId = "3d560ce4-a862-4792-953d-c0119cd0478b";
  xmlns = "http://ecs.amazonaws.com/doc/2013-08-01/";
   }]
  </code></pre>
  
  <p>So there is obviously something wrong with how I am creating my signature, can anyone guide me in the right direction?</p>