Convert.FromBase64String Error

M220N Chapter 3 User-Facing Backend
Ticket: User Management
Test = TestLogsInUser

TestLostsInUser() runs the PassworkHashOMantic Verify which calls
This convertion fails with the following error:

System.FormatException: ‘The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.’

//Fails when setting the hashBytes variable
public static bool Verify(string password, string hashedPassword)
var hashBytes = Convert.FromBase64String(hashedPassword);

            var salt = new byte[SaltSize]; //SaltSize is 16
            Array.Copy(hashBytes, 0, salt, 0, SaltSize); // source, index, dest, index, length = num elements to copy

            var pbkdf2 = new Rfc2898DeriveBytes(password, salt, Iterations);
            byte[] hash = pbkdf2.GetBytes(HashSize);

            for (var i = 0; i < HashSize; i++)
                if (hashBytes[i + SaltSize] != hash[i])
                    return false;

            return true;

Hi @Don_Krause, this topic seems to be related to:

Let us know if you are still facing issues while using this function.

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.