public static VerifyMachineCode_DES GetEncode_DES() { VerifyMachineCode_DES ret = new VerifyMachineCode_DES(); string str1 = ReadSystemHardDeviceParam.GetHardDisk_SerialNumber().Trim(); string str2 = ReadSystemHardDeviceParam.GetCPU_SerialNumber().Trim(); string str3 = ReadSystemHardDeviceParam.GetMacAddrs().Trim(); string str4 = ReadSystemHardDeviceParam.GetMasterBoard_SerialNumber().Trim(); byte[] b1 = Encoding.ASCII.GetBytes(str1); byte[] b2 = Encoding.ASCII.GetBytes(str2); byte[] b3 = Encoding.ASCII.GetBytes(str3); byte[] b4 = Encoding.ASCII.GetBytes(str4); byte[] ID = new byte[8]; for (int i = 0; i < 8; i++) { try { ID[i] = (byte)(b1[i] ^ b2[i] ^ b3[i] ^ b4[i]); } catch// (System.Exception ex) { ID[i] = (byte)'w'; } } lcyHashCal lcy = new lcyHashCal(); byte[] Encode = lcy.HashCal(ID, lcyNum); DESCrypto des = new DESCrypto(); ret.ID = des.EncryptString(StringsFunction.byteToHexStr(ID, ""), "wfMaCovf", "Machincd"); ret.Encode = des.EncryptString(StringsFunction.byteToHexStr(Encode, ""), "wfMaCovf", "Machincd"); return(ret); }
public static bool CheckEncode_DES(VerifyMachineCode_DES vc) { lcyHashCal lcy = new lcyHashCal(); DESCrypto des = new DESCrypto(); byte[] ID = StringsFunction.strToHexByte(des.DecryptString(vc.ID, "wfMaCovf", "Machincd"), ""); byte[] x = lcy.HashCal(ID, lcyNum); byte[] Encode = StringsFunction.strToHexByte(des.DecryptString(vc.Encode, "wfMaCovf", "Machincd"), ""); for (int i = 0; i < 8; i++) { if (x[i] != Encode[i]) { return(false); } } return(true); }