Azure IOT Hub - Device Security Token
<p>so we are using MQTT to connect device/server. I have everything working using a mock client using the M2Mqtt library. What im really struggling with is how to in code generate the <strong><em>signature</em></strong> used in the password field.</p>

<p>I followed this <a href="https://azure.microsoft.com/en-us/documentation/articles/iot-hub-sas-tokens/" rel="nofollow">https://azure.microsoft.com/en-us/documentation/articles/iot-hub-sas-tokens/</a> however im battling around the HMAC side of things. What is the "** signingKey**" they talk of? Is that the devices shared access key? For now just getting the mock client to create its own signature in code (not through the device explorer) is essential before we even worry if our products in the field can compute this (Finding this really over complicated for field devices). Is there a C# example somewhere I can follow other than the node.js - what does this line mean "hmac.update(toSign);"</p>

<p>Is there any simpler way to authenticate a device to the server? maybe just using its shared access key?</p>

<p>Sorry for all the questions :/ Probably I just need a step by step guide on what/when to do URI encode/Base64 encode/decode, HMAC 256 etc as I believe the documentation is far from sufficient. </p>

<p>"{signature}    An HMAC-SHA256 signature string of the form: {URL-encoded-resourceURI} + "\n" + expiry. Important: The key is decoded from base64 and used as key to perform the HMAC-SHA256 computation."</p>