Пример #1
0
        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));
        }
Пример #2
0
        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);
        }
Пример #3
0
        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));
        }