public void btnGenerate_Click(object sender, RoutedEventArgs e) { if ((txtCPUID.Text != null) && (txtCPUID.Text.Length >= 15) && (txtCPUID.Text.Length <= 16)) { string SBKCodeResult = ""; int l_sbkResult = SBKLibrary.GetEncoder(this.txtCPUID.Text, ref SBKCodeResult); if (SBKCodeResult != null && SBKCodeResult != "") { char[] rmChar = { '\\', '0' }; this.txtSBK.Text = SBKCodeResult.Remove((SBKCodeResult.Length - 1), 1); } } else { MessageBox.Show("Please, check your CPUID.", "CPUID Error"); } }
public unsafe static int GetEncoder(string CPUID, ref string SBKCodeResult) { byte[] array = new byte[44]; byte[] array2 = new byte[CPUID.Length]; for (int i = 0; i < CPUID.Length; i++) { array2[i] = (byte)CPUID[i]; } int result; fixed(byte *ptr = array) { fixed(byte *ptr2 = array2) { result = SBKLibrary.Encode(ptr2, array2.Length, ptr, array.Length); for (int j = 0; j < array.Length; j++) { SBKCodeResult += Convert.ToChar(array[j]); } } } return(result); }