我有下面的.net代码,我想知道它是如何工作的,有人可以用伪代码或英文解释它是如何工作的最好方法吗?
namespace Export
{
public class Licencing
{
public string licensingstr;
public string regvalue;
public bool IsLicenced(string ChkHdr)
{
if (ChkHdr == "Live System")
return true;
int num = 0;
for (int index = 0; index < ChkHdr.Length; ++index)
num += (int) ChkHdr[index];
return this.GetRegChkSum() == num * 31;
}
public void SetRegChkSum(string ChkSum)
{
RegistryKey subKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", true).CreateSubKey("Professional Services \\Configuration");
subKey.SetValue("MaxRows", (object) ChkSum);
subKey.Close();
}
private int GetRegChkSum()
{
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Professional Services \\Configuration");
if (registryKey == null)
return 0;
object obj = registryKey.GetValue("MaxRows");
if (obj == null)
return 0;
this.regvalue = Convert.ToString(obj);
this.regvalue = this.regvalue.Substring(1, this.regvalue.Length - 2);
registryKey.Close();
return int.Parse(this.regvalue, NumberStyles.HexNumber);
}
}
}
答案 0 :(得分:0)
就我所见,这是复制保护系统的一个例子。
var licenseChecker = new Licensing();
licenseChecker.IsLicenced(“Live System”);
//将返回true,只是一个用于测试puproses的模型
licenseChecker.IsLicenced( “钥匙”);
//在这里你得到evey char的int值之和的值(k为107),(e为101),y为121,并将它乘以31. 329 * 31为文本示例
//然后尝试从注册表项获取值,并检查它的子字符串是否为329 * 31的十六进制值。