private static string DecryptString(Rsa rsaKey, string encryptedText) { Debug.Assert(rsaKey != null); Debug.Assert(!string.IsNullOrEmpty(encryptedText)); byte[] encryptedBytes = LicenseManager.BytesFromString(encryptedText); byte[] decryptedBytes = rsaKey.Decrypt(encryptedBytes); return(Encoding.UTF8.GetString(decryptedBytes)); }
protected sealed override LicenseError Validate() { if (_verified) { Byte[] encryptedBytes = LicenseManager.BytesFromString(Data); Byte[] bytes = ProtectedData.Unprotect(encryptedBytes, null, DataProtectionScope.LocalMachine); if (new Guid(bytes) != Guid) { _error = new LicenseError(Assembly, LicenseErrorReason.InvalidLicense, Messages.InvalidMachineData, this); } _verified = true; } return(_error); }
internal string Decrypt(string encryptedText) { if (IsEmpty) { Byte[] bytes = Convert.FromBase64String(encryptedText); return(Encoding.UTF8.GetString(bytes)); } byte[] input = LicenseManager.BytesFromString(encryptedText); byte[] output; using (TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider()) { output = Transform(input, des.CreateDecryptor(GetTripleDesKey(_key), GetTripleDesIv(_key))); } return(Encoding.UTF8.GetString(output)); }