Edittext.Text显示正确的值,但使用了错误的

时间:2016-09-16 13:06:52

标签: c# android xamarin android-edittext textview

我在谷歌和论坛上搜索过,但没有发现任何有关我的奇怪问题的信息。为了我糟糕的英语而烦恼:)

这真的很奇怪而且很难,所以我想尽可能简单地描述它

  1. edittext中的用户输入(类型:textPassword):1 - >已登录 - >工作

    var loginResult = await connection.LoginAsync(this.Username.Text,this.Password.Text,WebLoginType.User);

  2. 密码将其加密为“2FYM9iWHHecf45vPjjZPfg ==”

    var newLogin = new LoginData                 {                     Username = this.Username.Text,                     密码= Encrypter.Encrypt(this.Password.Text),                     WebServiceAddress = this.WebServiceAddress.Text,                     IsOnline = true,                     IsActive = true,                     许可证= this._license                 };

  3. 现在注销时,密码再次以“1”解密,但在布局中我可以看到它在edittext中有多个字符。 this.Edittext.Text =“1”

    this.Password.SetText(Encrypter.Decrypt(setting.LastLoginPassword),TextView.BufferType.Normal);

  4. 如果我再次登录,我可以看到.Edittext.Text为“1”,但WebService表示密码错误

  5. 现在如果我删除edittext中的字符并手动编写“1”就可以了。 是什么魔法?

1 个答案:

答案 0 :(得分:0)

Solved Probem:加密器用\ u0000填充剩余的字节,直到它的大小为16字节。我不得不用

删除它
return Encoding.UTF8.GetString(result, 0, result.Length).TrimEnd('\u0000');

现在可行。