本文整理汇总了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 "";
}
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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 "";
}
}
示例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();
}
}
示例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.";
}
}
示例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" } };
}
示例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);
}
}
}