Repository: veler/DevToys
File: src/dev/impl/DevToys/ViewModels/Tools/Generators/HashGenerator/HashGeneratorToolViewModel.cs (C#)

Code before:
            }

            _calculationInProgress = true;

            await TaskScheduler.Default;

            while (_hashCalculationQueue.TryDequeue(out string? text))
            {
                Task<string> md5CalculationTask = CalculateHashAsync(HashAlgorithmNames.Md5, text);
                Task<string> sha1CalculationTask = CalculateHashAsync(HashAlgorithmNames.Sha1, text);
                Task<string> sha256CalculationTask = CalculateHashAsync(HashAlgorithmNames.Sha256, text);
                Task<string> sha512CalculationTask = CalculateHashAsync(HashAlgorithmNames.Sha512, text);

                await Task.WhenAll(md5CalculationTask).ConfigureAwait(false);

                ThreadHelper.RunOnUIThreadAsync(() =>
                {
                    MD5 = md5CalculationTask.Result;
                    SHA1 = sha1CalculationTask.Result;
                    SHA256 = sha256CalculationTask.Result;
                    SHA512 = sha512CalculationTask.Result;

                    if (!_toolSuccessfullyWorked)
                    {
                        _toolSuccessfullyWorked = true;
                        _marketingService.NotifyToolSuccessfullyWorked();
                    }
                }).ForgetSafely();
            }

            _calculationInProgress = false;
        }

        private async Task<string> CalculateHashAsync(string alrogithmName, string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return string.Empty;
            }

            await TaskScheduler.Default;

            try
            {
                var algorithmProvider = HashAlgorithmProvider.OpenAlgorithm(alrogithmName);

                IBuffer buffer = CryptographicBuffer.ConvertStringToBinary(text, BinaryStringEncoding.Utf8);
                buffer = algorithmProvider.HashData(buffer);

                string? hash="";
                if (OutputType == "Hex")

Review comment (suggestion):
Hello, 
I see that you compare two different values, can you use a String.Equals to do that?
And also please avoid using string directly here and define an internal for example, you can see and example in the "JsonYamlToolViewModel"
Thank you

Code after:
            {
                return;
            }

            _calculationInProgress = true;

            await TaskScheduler.Default;

            while (_hashCalculationQueue.TryDequeue(out string? text))
            {
                Task<string> md5CalculationTask = CalculateHashAsync(HashAlgorithmNames.Md5, text);
                Task<string> sha1CalculationTask = CalculateHashAsync(HashAlgorithmNames.Sha1, text);
                Task<string> sha256CalculationTask = CalculateHashAsync(HashAlgorithmNames.Sha256, text);
                Task<string> sha512CalculationTask = CalculateHashAsync(HashAlgorithmNames.Sha512, text);

                await Task.WhenAll(md5CalculationTask).ConfigureAwait(false);

                ThreadHelper.RunOnUIThreadAsync(() =>
                {
                    MD5 = md5CalculationTask.Result;
                    SHA1 = sha1CalculationTask.Result;
                    SHA256 = sha256CalculationTask.Result;
                    SHA512 = sha512CalculationTask.Result;

                    if (!_toolSuccessfullyWorked)
                    {
                        _toolSuccessfullyWorked = true;
                        _marketingService.NotifyToolSuccessfullyWorked();
                    }
                }).ForgetSafely();
            }

            _calculationInProgress = false;
        }

        private async Task<string> CalculateHashAsync(string alrogithmName, string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return string.Empty;
            }

            await TaskScheduler.Default;

            try
            {
                var algorithmProvider = HashAlgorithmProvider.OpenAlgorithm(alrogithmName);

                IBuffer buffer = CryptographicBuffer.ConvertStringToBinary(text, BinaryStringEncoding.Utf8);
                buffer = algorithmProvider.HashData(buffer);