forked from AGameAnx/dok-ge-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapModUtil.cs
40 lines (37 loc) · 1.14 KB
/
MapModUtil.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
// Token: 0x02000419 RID: 1049
public static class MapModUtil {
// Token: 0x06001670 RID: 5744
public static string GetHash(string data) {
if (data == "") {
return "NONE";
}
string str;
using (SHA256Managed sha256Managed = new SHA256Managed()) {
byte[] bytes = Encoding.UTF8.GetBytes(data);
str = BitConverter.ToString(sha256Managed.ComputeHash(bytes)).Replace("-", string.Empty).Substring(0, 6);
}
return str;
}
public static string GetHash(byte[] data) {
string str;
using (SHA256Managed sha256Managed = new SHA256Managed()) {
str = BitConverter.ToString(sha256Managed.ComputeHash(data)).Replace("-", string.Empty).Substring(0, 6);
}
return str;
}
// Token: 0x06001671 RID: 5745
public static string DownloadWebPage(string url, int timeoutMilliseconds = 5000) {
WebRequest webRequest = WebRequest.Create(url);
webRequest.Timeout = timeoutMilliseconds;
string result;
using (StreamReader sr = new StreamReader(webRequest.GetResponse().GetResponseStream())) {
result = sr.ReadToEnd();
}
return result;
}
}