0

In microsoft document (https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-dev-guide-sas?tabs=node#sas-token-structure) the method to generate the Azure IoTHub device SAS Token is provided for Node.js platform using crypto. But the same method is failing in react-native application.

Can anyone suggest a method/library which will work on react-native application?

Note: I have tried using react-js npm module using below method

import CryptoJS from 'crypto-js'

var hmac = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, deviceKey);
hmac.update(stringToSign);
var hash = CryptoJS.enc.Base64.stringify(hmac.finalize());
 console.log('hash: ', hash)

But the signature generated with above method is failing to authenticate with IoTHub device.

nkjs cloud
  • 11
  • 1

0 Answers0