• Hello and welcome to our new forums. We upgraded our forum sites to a more robust and modern system which we hope you will enjoy. Be sure to check out your profile by clicking the button on the top right and configure your preferences, signature, time zone, avatar, etc. as you wish. If you need help with using this new forum'ware try the help link on the bottom right.

    Click here to review your account now.

Question Code error

Compiler

New member
Joined
Apr 15, 2019
Messages
1
Programming Experience
Beginner
Hi everyone,
Can you help me find what conceptual problems exist in this exam question (regardless of library definitions):
C#:
string oneWayEncode(string plaintextPassword) {
   try {
      var digest = new SHA256Managed();
      digest.Initialize();
      //plaintextPassword = string.Concat(plaintextPassword, "salt.");
      byte[] data = digest.ComputeHash(System.Text.Encoding.UTF8.GetBytes(plaintextPassword));
      return Convert.ToBase64String(data);
   } catch (ArgumentNullException e) {
   } catch (ObjectDisposedException e) {
   }
}
 
bool login(string username, string password) {
   string storedPassword = db.lookupField(username, "password");
   return oneWayEncode(password) == oneWayEncode(storedPassword);
}
 
Last edited by a moderator:
Top Bottom