1
一個有效的Base-64字符串我從API服務器輸入是不是從StreamReader的
try
{
HttpWebRequest _request = (HttpWebRequest)WebRequest.Create(_url);
_request.KeepAlive = false;
using (HttpWebResponse _response = (HttpWebResponse)_request.GetResponse())
{
using (Stream _stream = _response.GetResponseStream())
{
using (StreamReader _reader = new StreamReader(_stream, Encoding.UTF8))
{
string _content = _reader.ReadToEnd();
Console.WriteLine(Decrypt(_content.ToString(), _key, _iv));
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
得到一個加密的字符串,但我發現了一個錯誤:
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.
怪異事情是,如果我複製返回的字符串進行解密罰款:
string str = "jcXddetnrE6ujO/Al1pqSRPK1+JXfal1XgANOsojPV9SUMOjnBgW09AacxhOUGYWZQoUlfsTEk/8Al1NuX/Gk/S2utUCLeEqHLrXwP5tkFgrrqUffHOzxWyD5vwIY2zQ";
Console.WriteLine(Decrypt(str, _key, _iv));
是否從StreamReader的字符串必須以某種方式轉變?
這個字符串來自哪裏?它包含複製它時已被刪除的引號的機會嗎?嘗試將加密的字符串打印到控制檯 – yonisha
您確定響應以UTF-8形式返回嗎? – Simon
它是一個基於web的API,所以格式爲' encryptedkeystring ' –
keeg