Example #1
0
        private static string EncryptString(Rsa rsaKey, string value)
        {
            Debug.Assert(rsaKey != null);
            Debug.Assert(!string.IsNullOrEmpty(value));

            byte[] bytes          = Encoding.UTF8.GetBytes(value);
            byte[] encryptedBytes = rsaKey.Encrypt(bytes);
            return(LicenseManager.BytesToString(encryptedBytes));
        }
Example #2
0
        private static string GetAssemblyHash(Assembly assembly)
        {
            foreach (object obj in GetEnumerable(assembly.Evidence.GetHostEnumerator()))
            {
                Hash hash = obj as Hash;
                if (hash != null)
                {
                    return(LicenseManager.BytesToString(hash.SHA1));
                }
            }

            return(null);
        }
Example #3
0
        internal string Encrypt(string text)
        {
            byte[] input = Encoding.UTF8.GetBytes(text);

            if (IsEmpty)
            {
                return(Convert.ToBase64String(input));
            }

            byte[] output;
            using (TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider())
            {
                output = Transform(input, des.CreateEncryptor(GetTripleDesKey(_key), GetTripleDesIv(_key)));
            }
            return(LicenseManager.BytesToString(output));
        }