Не работает активация - C#
Формулировка задачи:
Привет!
Я сделал привязку к железу, все нормально работает у меня.
Себе я могу активировать на сервере ключ, но у друзей не работает.
Может кто помочь?
Файл ключей, в скобках ключ.
Index
Так вот если я пишу в скобки свой ключ он активируется, а если чуть ниже такой же только друга то не активируется.
Кто знает где ошибка?
<?php $key[] = "тут мой ключ, он работает."; $key[] = "тут ключ друга, он не работает."; ?>
<?php
include 'base.php';
$_getkey = strip_tags(trim($_GET['idname']));
foreach ($key as $k)
{
if ($_getkey == $k)
{
echo 'Activated - '.$_getkey.'%';
}
else
{
echo 'Activated';
}
}
?>Решение задачи: «Не работает активация»
textual
Листинг программы
private Form5 form5;
public static string _key = CalculateMD5Hash(GetHWID()).ToLower();
public static string _isactivted = "Activated - " + _key + "%";
public static string _server = "тут ссылка на мой хостинг";
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(Form1_Load);
CheckHost();
TextBox1.Text = _key;
CheckHost();
if (GET(_server, _key))
{
Button1.Enabled = true;
Label2.Text = "Ключ активирован!";
}
}
public static string CalculateMD5Hash(string input)
{
// Primeiro passo, calcular o MD5 hash a partir da string
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
byte[] hash = md5.ComputeHash(inputBytes);
// Segundo passo, converter o array de bytes em uma string haxadecimal
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
sb.Append(hash[i].ToString("X2"));
}
return sb.ToString();
}
private static string GetHWID()
{
var mbs = new ManagementObjectSearcher("Select ProcessorId From Win32_processor");
ManagementObjectCollection mbsList = mbs.Get();
string id = "";
foreach (ManagementObject mo in mbsList)
{
id = mo["ProcessorId"].ToString();
break;
}
return id;
}
private static bool GET(string Url, string Data)
{
System.Net.WebRequest req = System.Net.WebRequest.Create(Url + "?idname=" + Data);
System.Net.WebResponse resp = req.GetResponse();
System.IO.Stream stream = resp.GetResponseStream();
System.IO.StreamReader sr = new System.IO.StreamReader(stream);
string Out = sr.ReadToEnd();
sr.Close();
if (_isactivted.Equals(Out))
{
return true;
}
else return false;
}