Exemplo n.º 1
0
        private async void SendExecute()
        {
            IsLoading = true;

            var passwordResponse = await LegacyService.GetPasswordAsync();

            if (passwordResponse.IsSucceeded)
            {
                if (passwordResponse.Result is TLAccountPassword password)
                {
                    var currentSalt = password.CurrentSalt;
                    var hash        = TLUtils.Combine(currentSalt, Encoding.UTF8.GetBytes(_password), currentSalt);

                    var input  = CryptographicBuffer.CreateFromByteArray(hash);
                    var hasher = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256);
                    var hashed = hasher.HashData(input);
                    CryptographicBuffer.CopyToByteArray(hashed, out byte[] data);

                    var response = await LegacyService.GetTmpPasswordAsync(data, 60 * 30);

                    if (response.IsSucceeded)
                    {
                        ApplicationSettings.Current.TmpPassword = response.Result;
                        //NavigationService.NavigateToPaymentFormStep5(_message, _paymentForm, _info, _requestedInfo, _shipping, null, null, true);
                    }
                    else if (response.Error != null)
                    {
                        IsLoading = false;

                        if (response.Error.TypeEquals(TLErrorType.PASSWORD_HASH_INVALID))
                        {
                            Password = string.Empty;
                            RaisePropertyChanged(response.Error.ErrorMessage);
                        }
                        else
                        {
                        }
                    }
                }
                else
                {
                }
            }
            else if (passwordResponse.Error != null)
            {
                IsLoading = false;
            }
        }