public static SysInfo GetComputerId() { string assemblyName = Assembly.GetExecutingAssembly().GetName().Name; SystemInfo.UseProcessorID = true; SystemInfo.UseBaseBoardProduct = true; SystemInfo.UseBaseBoardManufacturer = true; SystemInfo.UseDiskDriveSignature = true; SystemInfo.UseVideoControllerCaption = true; SystemInfo.UsePhysicalMediaSerialNumber = true; SystemInfo.UseBiosVersion = true; SystemInfo.UseBiosManufacturer = true; SystemInfo.UseWindowsSerialNumber = true; string sysInfoTmp = SystemInfo.GetSystemInfo(assemblyName); sysInfoTmp = SerialNumbersSettings.ProtectedApplications.SaltData.GeneralToolkit + sysInfoTmp + SerialNumbersSettings.ProtectedApplications.SaltData.GeneralToolkit; byte[] sysInfoBytes = Encoding.ASCII.GetBytes(sysInfoTmp); byte[] cumputerIdBytes; using (var hashAlg = SHA512.Create()) { cumputerIdBytes = hashAlg.ComputeHash(sysInfoBytes); } byte[] rsaSignedHashBytes = SerialNumberManager.HashAndSignBytes(cumputerIdBytes, RsaLocalCryptoKeyManager.GetAssemblyRsaParameters()); return(new SysInfo(Converters.GeneralConverters.ByteArrayToBase64(cumputerIdBytes), Converters.GeneralConverters.ByteArrayToBase64(rsaSignedHashBytes))); }
public void Init(SerialNumbersSettings.ProtectedApp app) { string pubKey; switch (app) { case SerialNumbersSettings.ProtectedApp.SecureMemo: pubKey = SerialNumbersSettings.ProtectedApplications.PublicKeys.SecureMemo; break; case SerialNumbersSettings.ProtectedApp.SearchForDuplicates: pubKey = SerialNumbersSettings.ProtectedApplications.PublicKeys.SearchForDuplicates; break; default: throw new ArgumentOutOfRangeException("app"); } RsaAsymmetricEncryption rsaAsymmetricEncryption = new RsaAsymmetricEncryption(); RSAKeySetIdentity rsaPublicKeySetIdentity = new RSAKeySetIdentity("", pubKey); RSAParameters rsaPublicKey = rsaAsymmetricEncryption.ParseRSAPublicKeyOnlyInfo(rsaPublicKeySetIdentity); _serialNumberManager = new SerialNumberManager(rsaPublicKey, app); }