/// <summary> /// Checks a single word (or rather a variation of a word): Encrypts and compares to all entries in the password file /// </summary> /// <param name="userInfos"></param> /// <param name="possiblePassword">List of (username, encrypted password) pairs from the password file</param> /// <returns>A list of (username, readable password) pairs. The list might be empty</returns> private IEnumerable <FullUser> CheckSingleWord(IEnumerable <UserInfo> userInfos, String possiblePassword) { char[] charArray = possiblePassword.ToCharArray(); byte[] passwordAsBytes = Array.ConvertAll(charArray, PasswordFileHandler.GetConverter()); byte[] encryptedPassword = HashAlgorithm.ComputeHash(passwordAsBytes); //string encryptedPasswordBase64 = System.Convert.ToBase64String(encryptedPassword); List <FullUser> results = new List <FullUser>(); foreach (UserInfo userInfo in userInfos) { if (PasswordUtils.CompareBytes(userInfo.EntryptedPassword, encryptedPassword)) { results.Add(new FullUser(userInfo.Username, possiblePassword)); Console.WriteLine(userInfo.Username + " " + possiblePassword); } } return(results); }