我有下面的。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);
}
}
}
据我所知,这是一个复制保护系统的例子。
var licenseChecker = new licensing ();
licenseChecker。IsLicenced("实时系统");
//将返回true,只是一个用于测试目的的模型
licenseChecker.IsLicenced("关键");
//这里你得到每个字符的int值之和的值(k为107),(e为101),(y为121),并将其相乘为31。329*31为文本示例
//然后你尝试从注册表项中获取值,并检查它的子字符串是否为329*31的十六进制值