Creating a very simple user database

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)); 
} 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.238.76