-2
我正在使用WIX和C#自定義操作來解鎖產品。 我們已經計劃修改我們的解鎖密鑰,如(34450-ee33-8736333-30393)從舊式。 您能否讓我知道哪種算法適合這個?提供在線材料來學習這一點會很有用。
如果您需要任何信息,請讓我知道。生成解鎖密鑰
我正在使用WIX和C#自定義操作來解鎖產品。 我們已經計劃修改我們的解鎖密鑰,如(34450-ee33-8736333-30393)從舊式。 您能否讓我知道哪種算法適合這個?提供在線材料來學習這一點會很有用。
如果您需要任何信息,請讓我知道。生成解鎖密鑰
您可以在System.Net.Security和System.Net.Security.Cryptography中使用各種加密類。我特別使用類似MD5CryptoServiceProvider的類來計算二進制塊或文件的哈希值,並輸出與您提到的類似的摘要。然後,您可以匹配生成的系統和用戶輸入鍵來激活/解鎖軟件。
這裏是我的密碼努力的一個樣本:
byte[] bytes = System.IO.File.ReadAllBytes(ofd.FileName);
byte[] checksum = null;
if (optMD5.IsChecked==true)
{
MD5 md5 = System.Security.Cryptography.MD5.Create();//.MD5CryptoServiceProvider();
checksum=new byte[1024];
checksum = md5.ComputeHash(bytes);
}
else if (optSHA1.IsChecked == true)
{
SHA1 sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
checksum = sha1.ComputeHash(bytes);
}
else {
MessageBox.Show("No option selected.");
return;
}
//string schecksum = BitConverter.ToString(checksum);//ASCIIEncoding.ASCII.GetString(checksum);
// Create a new Stringbuilder to collect the bytes
// and create a string.
StringBuilder sb = new StringBuilder();
// Loop through each byte of the hashed data
// and format each one as a hexadecimal string.
for (int i = 0; i < checksum.Length; i++)
{
sb.Append(checksum[i].ToString("x2"));
}
// Return the hexadecimal string.
//return sb.ToString();
MessageBox.Show("checksum-1 = " + sb.ToString() + Environment.NewLine + "checksum-2 = " + txtChecksum.Text);
'BOOL的IsValid {返回true;}' – CodesInChaos 2012-07-25 11:19:28