提交 a2ff3342 编写于 作者: 麦壳饼's avatar 麦壳饼

Using http protocol is insecure. Use https instead.

Make sure that using this pseudorandom number generator is safe here.
上级 2a7bd22a
......@@ -93,8 +93,8 @@ namespace IoTSharp.Controllers
int buzzleHeight = buzzle.Height;
int oriImageWidth = original.Width;
int oriImageHeight = original.Height;
int randomlocaltionx = random.Next(oriImageWidth - 2 * buzzleWidth) + buzzleWidth;
int randomlocaltiony = random.Next(oriImageHeight - buzzleHeight);
int randomlocaltionx = RandomNumberGenerator.GetInt32(oriImageWidth - 2 * buzzleWidth) + buzzleWidth;
int randomlocaltiony = RandomNumberGenerator.GetInt32(oriImageHeight - buzzleHeight);
return Cut(original, buzzle, randomlocaltionx, randomlocaltiony, buzzleWidth, buzzleHeight);
}
......
......@@ -255,7 +255,6 @@ namespace IoTSharp.Controllers
string q = Words;
string from = _profile.Value.DefaultLang ?? "zh";
string appId = _profile.Value.AppKey;
Random rd = new Random (DateTime.Now.Millisecond);
string secretKey = _profile.Value.AppSecret;
int _wait = _profile.Value.ApiInterval ?? 80;
List<BaiduTranslateResult> l = new List<BaiduTranslateResult>();
......@@ -265,9 +264,9 @@ namespace IoTSharp.Controllers
string to = item.Target;
using (HttpClient client = new HttpClient())
{
string salt = rd.Next(100000).ToString();
string salt = RandomNumberGenerator.GetInt32(100000).ToString();
string sign = EncryptString(appId + q + salt + secretKey);
string url = "http://api.fanyi.baidu.com/api/trans/vip/translate?";
string url = "https://api.fanyi.baidu.com/api/trans/vip/translate?";
url += "q=" + HttpUtility.UrlEncode(q);
url += "&from=" + from;
url += "&to=" + to;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册