kylecharlesbotha / SEN381-Project

Software Engineering 381 Project/Belgium Campus
0 stars 0 forks source link

Finish Methods for frmCreateAccount #77

Closed DarrenOosthuizen closed 3 years ago

DarrenOosthuizen commented 3 years ago

Hi There

Please create and finish all the methods needed for frmCreateAccount

Please implement the following:

private String CreateSalt(int size)
        {
            var rng = new RNGCryptoServiceProvider();
            var buff = new byte[size];
            rng.GetBytes(buff);
            return Convert.ToBase64String(buff);
        }

Store that salt in local var and also in object of User Now use that salt and the users password which they entered and create a hash by calling CreateSHA256Hash Method:

public String CreateSHA256Hash(string input, string salt)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(input + salt);
            SHA256Managed sha256hashstring = new SHA256Managed();
            byte[] hash = sha256hashstring.ComputeHash(bytes);

            return ByteArrayToStrng(hash);
        }
        private static string ByteArrayToStrng(byte[] ba)
        {
            StringBuilder hex = new StringBuilder(ba.Length * 2);
            foreach (byte b in ba)
            {
                hex.AppendFormat("{0:x2}", b);
            }
            return hex.ToString();
        }

Then store that hash password inside the object and now create account

PS!! Please Loop through program from going from Presentation Layer ---> Business Access Layer - Dataaccess layer so that bubbling it implemented

ClaudePretorius commented 3 years ago

Hi there.

frmCreateAccount.cs is finished with all the required methods.