The user database will only contain our one user. We leave it to the reader to create a more dynamic user database:
private IUserSource users = new Users(); public class Users : IUserSource { public bool TryGetUser(string UserName, out IUser User) { if (UserName == "MIoT") User = new User(); else User = null; return User != null; } }
We also define our salted hash function as follows, using the unique device identity as the salt:
private string CalcHash(string Password) { return Waher.Security.Hashes.ComputeSHA256HashString( Encoding.UTF8.GetBytes(Password + ":" + this.deviceId)); }