-
Notifications
You must be signed in to change notification settings - Fork 8
/
help
85 lines (75 loc) · 2.95 KB
/
help
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Diagnostics;
namespace TlsGameDemo1
{
public class Helper
{
/// <summary>
/// 返回处理后的Token(字节数组)
/// </summary>
/// <param name="ClientIV"></param>
/// <param name="ServerIV"></param>
/// <param name="Token"></param>
/// <param name="dwMajor"></param>
/// <param name="dwMinor"></param>
/// <param name="dwBuildNumber"></param>
/// <param name="dwRevision4"></param>
/// <returns></returns>
public static byte[] GetDecryptedBytesKey(byte[] ClientIV, byte[] ServerIV, byte[] Token, int dwMajor, int dwMinor, int dwBuildNumber, int dwRevision4)
{
byte[] ReturnToken = new byte[24];
Token.CopyTo(ReturnToken, 0);
;
for (int i = 0; i < 24; i++)
{
if (i % 4 < 1) ReturnToken[i] += (byte)dwMajor;
if (i % 4 < 2) ReturnToken[i] += (byte)(dwMinor + i);
if (i % 4 < 3) ReturnToken[i] += (byte)(dwBuildNumber - i); ;
ReturnToken[i] += (byte)(i ^ dwRevision4);
ReturnToken[i] ^= ClientIV[(i + 8) % 16];
ReturnToken[i] ^= ServerIV[(i + 8) % 16];
}
return ReturnToken;
}
/// <summary>
/// 获取处理后的Token(base64字符串)
/// </summary>
/// <param name="ClientIV"></param>
/// <param name="ServerIV"></param>
/// <param name="Token"></param>
/// <param name="dwMajor"></param>
/// <param name="dwMinor"></param>
/// <param name="dwBuildNumber"></param>
/// <param name="dwRevision4"></param>
/// <returns></returns>
public static string GetDecryptedKey(byte[] ClientIV, byte[] ServerIV, byte[] Token, int dwMajor, int dwMinor, int dwBuildNumber, int dwRevision4)
{
byte[] ReturnToken = GetDecryptedBytesKey(ClientIV, ServerIV, Token, dwMajor, dwMinor, dwBuildNumber, dwRevision4);
return Convert.ToBase64String(ReturnToken);
}
/// <summary>
/// 获取文件版本信息
/// </summary>
/// <param name="filepath"></param>
/// <returns></returns>
public static string GetFileInfo(string filepath)
{
FileVersionInfo file = FileVersionInfo.GetVersionInfo(filepath);
String Version = file.FileMajorPart + "|" + file.FileMinorPart + "|" + file.FileBuildPart + "|" + file.FilePrivatePart;
return Version;
}
//转16进制字符串
public static string BytesToString(byte[] bytes)
{
//有分隔符的api
return BitConverter.ToString(bytes);
//或者自己遍历
//string strRet = "";
//for (int i = 0; i < bytes.Length; i++)
//{
// strRet += bytes[i].ToString("X2");
//}
//return strRet;
}
}
}