当前位置: 首页>>代码示例>>C#>>正文


C# Encryption.Encrypt方法代码示例

本文整理汇总了C#中Encryption.Encrypt方法的典型用法代码示例。如果您正苦于以下问题:C# Encryption.Encrypt方法的具体用法?C# Encryption.Encrypt怎么用?C# Encryption.Encrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Encryption的用法示例。


在下文中一共展示了Encryption.Encrypt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerationKey

        public static string GenerationKey(string strSystemInfoKey)
        {
            try
            {
                string text1 = strSystemInfoKey.Split(new char[] { '-' })[0].ToUpper();
                string text2 = strSystemInfoKey.Split(new char[] { '-' })[1].ToUpper();
                string text3 = strSystemInfoKey.Split(new char[] { '-' })[2].ToUpper();
                string text4 = strSystemInfoKey.Split(new char[] { '-' })[3].ToUpper();
                string text5 = strSystemInfoKey.Split(new char[] { '-' })[4].ToUpper();

                //Mã hóa key
                Encryption enc = new Encryption(UserName, Password);
                text1 = SystemInfo.RemoveUseLess(enc.Encrypt(text1).ToUpper());
                text2 = SystemInfo.RemoveUseLess(enc.Encrypt(text2).ToUpper());
                text3 = SystemInfo.RemoveUseLess(enc.Encrypt(text3).ToUpper());
                text4 = SystemInfo.RemoveUseLess(enc.Encrypt(text4).ToUpper());
                text5 = SystemInfo.RemoveUseLess(enc.Encrypt(text5).ToUpper());

                return text1.Substring(0, 5) + "-" + text2.Substring(0, 5) + "-" + text3.Substring(0, 5) + "-" + text4.Substring(0, 5) + "-" + text5.Substring(0, 5);
            }
            catch(Exception ex)
            {
                return "";
            }
        }
开发者ID:romeobk,项目名称:HRMS_7Cua,代码行数:25,代码来源:License.cs

示例2: SetUp

        public void SetUp()
        {
            var e = new Encryption();

            param = new OracleClient { Name = "TestName", ClientName = "TestClientName", ConnectionString = "", Path = "path" };
            param.ConnectionString = e.Encrypt(Cs);
            log = MockRepository.GenerateMock<ILog>();
            encryption = MockRepository.GenerateMock<IEncryption>();
            encryption.Expect(x => x.Decrypt(e.Encrypt(Cs))).Return(Cs);
            //encryption.Expect(x => x.Encrypt("abc")).Return(ConnectionString);
        }
开发者ID:perryofpeek,项目名称:SqlToGraphitePlugin-Oracle,代码行数:11,代码来源:With_OracleClient.cs

示例3: btnEncrypt_Click

 private void btnEncrypt_Click(object sender, EventArgs e)
 {
     _type = (Tritemius.OffsetType)cmbEncryptionType.SelectedItem;
     _encryption = new Tritemius(rtbInput.Text, tbKey.Text, _type);
     rtbOutput.Clear();
     rtbOutput.Text = _encryption.Encrypt();
 }
开发者ID:NotYours180,项目名称:Encryption,代码行数:7,代码来源:TritemiusForm.cs

示例4: SetUp

 public void SetUp()
 {
     e = new Encryption();
     encryption = MockRepository.GenerateMock<IEncryption>();
     log = MockRepository.GenerateMock<ILog>();
     encryption.Expect(x => x.Decrypt(e.Encrypt(ConnectionString))).Return(ConnectionString);
 }
开发者ID:perryofpeek,项目名称:SqlToGraphitePlugin-SqlServer,代码行数:7,代码来源:With_SqlServerClient.cs

示例5: EncryptDecrypt

        public void EncryptDecrypt()
        {
            var enc = new Encryption();

            var encrypted = enc.Encrypt(message.ToBytes(), encKey.ToBytes());
            var encrypted2 = enc.Encrypt(message.ToBytes(), encKey.ToBytes());

            Assert.IsTrue(encrypted.Length == encrypted2.Length);
            Assert.IsFalse(Enumerable.SequenceEqual(encrypted, encrypted2));

            var decrypted = enc.Decrypt(encrypted, encKey.ToBytes());
            var decryptedString = decrypted.ToUtf8();
            var decrypted2 = enc.Decrypt(encrypted2, encKey.ToBytes());
            var decryptedString2 = decrypted2.ToUtf8();

            Assert.AreEqual(message, decryptedString);
            Assert.AreEqual(message, decryptedString2);
        }
开发者ID:nordseth,项目名称:blog,代码行数:18,代码来源:EncryptionTest.cs

示例6: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            DatabaseConnection dc = new DatabaseConnection();
            Encryption en = new Encryption();

            string join = textBox3.Text + en.Encrypt(textBox7.Text) + "'";

               // dc.insertData(textBox2.Text, textBox1.Text, join);

            MessageBox.Show("Data inserted");
        }
开发者ID:Ana-M-E,项目名称:shoesrus,代码行数:11,代码来源:MainForm.cs

示例7: btnEncrypt_Click

 private void btnEncrypt_Click(object sender, EventArgs e)
 {
     _encryption = new Gamma(rtbInput.Text, tbKey.Text);
     tbKey.Clear();
     rtbOutput.Clear();
     rtbOutput.Text = _encryption.Encrypt();
     tbKey.Text = _encryption.Key;
     using (var file = new StreamWriter("key.txt"))
     {
         file.WriteLine(_encryption.Key);
     }
 }
开发者ID:NotYours180,项目名称:Encryption,代码行数:12,代码来源:GammaForm.cs

示例8: ProcessPostRequest

        /// <summary>
        /// Handles encryption of the session data into a HTTP cookie.
        /// </summary>
        /// <param name="context"></param>
        public static void ProcessPostRequest(HttpContextBase context)
        {
            var session = GetSession(context, false);
            if (session == null || !session.IsDirty)
            {
                return;
            }

            var plaintext = SessionSerializer.Serialize(session);
            var encryption = new Encryption(Configuration.EncryptionKey, Configuration.SignatureKey);
            var encrypted = encryption.Encrypt(plaintext);

            var cookies = new CookieHelper(Configuration.CookieName);
            cookies.Set(context, encrypted);
        }
开发者ID:schmuli,项目名称:AspNetClientSessions,代码行数:19,代码来源:ClientSession.cs

示例9: Encryption_IgnoreTamperedValues

        public void Encryption_IgnoreTamperedValues()
        {
            const string secret = "a secret key";

            var encryptionKey = Hmac.Digest(secret, "clientsession-encryption");
            var signatureKey = Hmac.Digest(secret, "clientsession-signature");

            var encryption = new Encryption(encryptionKey, signatureKey);

            const string content = "some plain text content";
            var encrypted = encryption.Encrypt(content);
            var result2 = encryption.Decrypt(encrypted.Replace(encrypted[4], 'r'));

            Assert.IsNull(result2);
        }
开发者ID:schmuli,项目名称:AspNetClientSessions,代码行数:15,代码来源:EncryptionTests.cs

示例10: Encryption_EncryptDecrypt

        public void Encryption_EncryptDecrypt()
        {
            const string secret = "a secret key";

            var encryptionKey = Hmac.Digest(secret, "clientsession-encryption");
            var signatureKey = Hmac.Digest(secret, "clientsession-signature");

            var encryption = new Encryption(encryptionKey, signatureKey);

            const string content = "some plain text content";
            var encrypted = encryption.Encrypt(content);
            var result = encryption.Decrypt(encrypted);

            Assert.AreEqual(content, result);
        }
开发者ID:schmuli,项目名称:AspNetClientSessions,代码行数:15,代码来源:EncryptionTests.cs

示例11: EncryptQueryString

 public static string EncryptQueryString(string strQueryString)
 {
     Encryption xx = new Encryption();
     if (strQueryString == "")
     {
         return "";
     }
     try
     {
         return xx.Encrypt(strQueryString, "!D#2%vin");
     }
     catch (Exception ex)
     {
         return "";
     }
 }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:16,代码来源:Encryption.cs

示例12: Main

        //String testStr2 = "";
        //String testStr3 = "";
        //String testStr4 = "";
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            Encryption coder = new Encryption();
            string encodeTestStr1 = coder.Encrypt(testStr1, 1);
            string decodeTestStr1 = coder.Decrypt(encodeTestStr1, 1);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("FINAL RESULTS testStr1       = " + testStr1);
            Console.WriteLine("FINAL RESULTS encodeTestStr1 = " + encodeTestStr1);
            Console.Write("FINAL RESULTS decodeTestStr1 = ");
            Console.WriteLine(decodeTestStr1);

            using (Game1 game = new Game1())
            {
                game.Run();
            }
        }
开发者ID:nsbgamer,项目名称:NSBRTS,代码行数:24,代码来源:Program.cs

示例13: btnSubmit_Click

		private void btnSubmit_Click(object sender, System.EventArgs e)
		{
			Encryption enc = new Encryption("FlexRadio Systems", "PowerSDR");
            string text = enc.Encrypt(txtUser.Text + "/" + txtPass.Text);
			if(text == data)
			{
				MessageBox.Show("Access Granted");
				console.Extended = true;
				
				ArrayList a = new ArrayList();
                a.Add("extended/" + text);
				DB.SaveVars("State", ref a);
                
				this.Close();
				return;
			}
			else
			{
				count--;
				if(count == 0)
				{
					MessageBox.Show("Access Denied");
					this.Close();
					return;
				}
                statusBar1.Text = "Invalid User/Pass.  " + count.ToString() + " tries left.";
			}
		}
开发者ID:wa1gon,项目名称:PowerSDR,代码行数:28,代码来源:logon.cs

示例14: ForgotPassword

        public JsonResult ForgotPassword(ForgotPasswordViewModel model)
        {
            var user = _crmUserRepository.GetSingle(new { Email = model.Email });

            if (user == null)
            {
                return new JsonResult { Data = new { error = true, message = "There are no users with the indicated Email" } };
            }

             var encrypt = new Encryption();
            var pass = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 8);
            user.Password = encrypt.Encrypt(pass, user.Salt);
            _crmUserRepository.Update(user);
            _emailOperations.SendResetPasswordNotification(user.Name, model.Email, pass);
            return new JsonResult { Data = new { message = "An Email with you new password has been sent to your email address" } };
        }
开发者ID:pedro-ramirez-suarez,项目名称:rawtemplate,代码行数:16,代码来源:SignOnController.cs

示例15: WireUpTheClientObjectWithUiValues

        private void WireUpTheClientObjectWithUiValues()
        {
            foreach (PropertyInfo property in this.client.GetType().GetProperties())
            {
                string value = string.Empty;
                if (property.Name == "Type")
                {
                    value = this.client.GetType().FullName;
                }
                else if (property.Name == "ClientName")
                {
                    value = this.GetComboValue(property.Name);
                }
                else
                {
                    value = this.GetTextBoxValue(property.Name);
                }
                //This is a rubbish implementation , but it will do for now
                //TODO:Make this more generic
                if (property.PropertyType.Name == typeof(Int32).Name)
                {
                    property.SetValue(this.client, Convert.ToInt32(value), null);
                }

                if (property.PropertyType.Name == typeof(string).Name)
                {

                    var help = GetHelp(property);

                    if (IsEncrypted(property))
                    {
                        var encryption = new Encryption();
                        property.SetValue(this.client, encryption.Encrypt(value), null);
                    }
                    else
                    {
                        property.SetValue(this.client, value, null);
                    }
                }

                if (property.PropertyType.Name == typeof(bool).Name)
                {
                    property.SetValue(this.client, Convert.ToBoolean(value), null);
                }
            }
        }
开发者ID:perryofpeek,项目名称:SqlToGraphite-core,代码行数:46,代码来源:BuilderBase.cs


注:本文中的Encryption.Encrypt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。