private static string ComputeDerivedSymmetricKey()

in Hands-on lab/lab-files/starter-project/SmartMeterSimulator/DeviceManager.cs [57:71]


        private static string ComputeDerivedSymmetricKey(string enrollmentKey, string deviceId)
        {
            if (string.IsNullOrWhiteSpace(enrollmentKey))
            {
                return enrollmentKey;
            }

            var key = "";
            using (var hmac = new HMACSHA256(Convert.FromBase64String(enrollmentKey)))
            {
                key = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(deviceId)));
            }

            return key;
        }