O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Authenticating the user

The authentication method used in our application is simple. It checks the user database to see if a user with the given name is available. Then it checks the password hash method used and calculates the corresponding hash of the provided password. If the hashes match, credentials are authenticated. If not, or if the hash method is not recognized, authentication fails:

private IUser Login(string UserName, string Password) { if (this.users.TryGetUser(UserName, out IUser User)) { switch (User.PasswordHashType) { case "": if (Password == User.PasswordHash) return User; break; case "SHA-256": if (this.CalcHash(Password) == User.PasswordHash) return User; break; default: Log.Error("Unsupported Hash function: " + User.PasswordHashType); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required