本文整理汇总了C#中Encryption.Decrypt方法的典型用法代码示例。如果您正苦于以下问题:C# Encryption.Decrypt方法的具体用法?C# Encryption.Decrypt怎么用?C# Encryption.Decrypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encryption
的用法示例。
在下文中一共展示了Encryption.Decrypt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnForward_Click
private void btnForward_Click(object sender, EventArgs e)
{
_counter++;
if(_counter > _encryption.LetterCount)
_counter = 0;
tbKey.Text = _counter.ToString();
_encryption = new Caesar(rtbInput.Text, _counter.ToString());
rtbOutput.Text = _encryption.Decrypt();
}
示例2: 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);
}
示例3: btnEncrypt_Click
private void btnEncrypt_Click(object sender, EventArgs e)
{
_encryption = new Caesar(rtbInput.Text, tbKey.Text);
try
{
rtbOutput.Text = _encryption.Decrypt();
}
catch
{
MessageBox.Show("Данные введены неверно!");
}
}
示例4: 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);
}
示例5: 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);
}
示例6: DecryptQueryString
public static string DecryptQueryString(string strQueryString)
{
Encryption xx = new Encryption();
if (strQueryString == "")
{
return "";
}
try
{
return xx.Decrypt(strQueryString.Replace(" ", "+"), "!D#2%vin");
}
catch (Exception ex)
{
return "";
}
}
示例7: 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();
}
}
示例8: ProcessPreRequest
/// <summary>
/// Handles decryption of the Session cookie value. Resets the session after
/// expiration.
/// </summary>
/// <param name="context"></param>
public static void ProcessPreRequest(HttpContextBase context)
{
var cookies = new CookieHelper(Configuration.CookieName);
var encrypted = cookies.Gets(context);
if (string.IsNullOrEmpty(encrypted))
{
return;
}
var encryption = new Encryption(Configuration.EncryptionKey, Configuration.SignatureKey);
var decrypted = encryption.Decrypt(encrypted);
if (string.IsNullOrEmpty(decrypted))
{
return;
}
var session = SessionSerializer.Deserialize(decrypted);
if (session.CreatedAt + session.Duration < DateTime.UtcNow)
{
session.Reset(Configuration.Duration);
}
context.Items[ItemKey] = session;
}
示例9: btnDecrypt_Click
private void btnDecrypt_Click(object sender, EventArgs e)
{
_encryption = new Tritemius(rtbInput.Text, tbKey.Text, _type);
rtbOutput.Clear();
rtbOutput.Text = _encryption.Decrypt();
}
示例10: decryptString
public static string decryptString(string passwordEncrypted )
{
string decryptedPassword;
if (passwordEncrypted == null) return (null);
if (passwordEncrypted.Length < 1) return (null);
if (keyString == null) return (null);
if (keyString.Length < 1) return (null);
Encryption decrypter = new Encryption(Encryption.EncryptionTypes.DES);
decrypter.Salt = salt;
decrypter.Password = keyString;
decryptedPassword = decrypter.Decrypt(passwordEncrypted);
return (decryptedPassword);
}
示例11: EncryptionTestCerts
public void EncryptionTestCerts()
{
// Files already created and to be used
// _Test_Encryption.cer
// _Test_Encryption.pfx
// _Test_Encryption_Password.txt
var encryption = new Encryption();
var toEncrypt = "Hello world!";
//var toEncrypt = System.IO.File.ReadAllText(@"C:\_large_text.txt");
//var toEncryptBytes = Encoding.UTF8.GetBytes(toEncrypt);
var cert = System.IO.File.ReadAllBytes(@"C:\_Test_Encryption.cer");
var encrypted = encryption.Encrypt(cert, toEncrypt);
var pfx = System.IO.File.ReadAllBytes(@"C:\_Test_Encryption.pfx");
var password = System.IO.File.ReadAllText(@"C:\_Test_Encryption_Password.txt");
var decrypted = (string)encryption.Decrypt(pfx, password, encrypted);
Assert.AreEqual(toEncrypt, decrypted);
}
示例12: btnDecrypt_Click
private void btnDecrypt_Click(object sender, EventArgs e)
{
_encryption = new Gamma(rtbInput.Text, tbKey.Text);
rtbOutput.Clear();
rtbOutput.Text = _encryption.Decrypt();
}
示例13: loadSettings
private void loadSettings()
{
var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var filename = Path.Combine(documents, "proscanalert_settings.xml");
if (File.Exists(filename))
{
Settings s = new Settings();
XmlSerializer deserializer = new XmlSerializer(typeof(Settings));
TextReader textReader = new StreamReader(filename, Encoding.UTF8);
s = (Settings)deserializer.Deserialize(textReader);
textReader.Close();
Encryption enc = new Encryption();
tbServerHost.Text = s.host;
tbServerPort.Text = s.port;
//tbLocalPort.Text = s.lport;
tbPassword.Text = enc.Decrypt(s.pass);
tbMins.Text = string.IsNullOrEmpty(s.mins) ? "60" : s.mins;
tbSecs.Text = string.IsNullOrEmpty(s.secs) ? "30" : s.secs;
enc = null;
s = null;
}
}
示例14: GetPropertyValue
protected string GetPropertyValue(ISqlClient typedJob, PropertyInfo property)
{
string rtn;
if (property == null)
{
rtn = string.Empty;
}
else
{
object obj = null;
if (this.IsEncrypted(property))
{
var encryption = new Encryption();
var v = property.GetValue(typedJob, null);
if(v != null)
{
var value = v.ToString();
if (value != string.Empty)
{
obj = encryption.Decrypt(property.GetValue(typedJob, null).ToString());
}
}
}
else
{
obj = property.GetValue(typedJob, null);
}
rtn = obj == null ? string.Empty : obj.ToString();
}
return rtn;
}
示例15: Read12
public void Read12(string fileIn)
{
BinaryReader br = new BinaryReader(File.OpenRead(fileIn));
// Read header
ushort bpp = br.ReadUInt16();
int width = br.ReadByte() * 8;
int height = br.ReadByte() * 8;
ushort map_offset = br.ReadUInt16();
ushort map_size = br.ReadUInt16();
ushort data_offset = br.ReadUInt16();
ushort data_size = br.ReadUInt16();
ushort pal_offset = br.ReadUInt16();
ushort pal_size = br.ReadUInt16();
// Read map
br.BaseStream.Position = map_offset;
NTFS[] map = new NTFS[map_size / 2];
for (int i = 0; i < map.Length; i++)
map[i] = Actions.MapInfo(br.ReadUInt16());
Set_Map(map, false, width, height);
// Read image data
ColorFormat format = ColorFormat.colors256;
if (bpp == 0x12 || bpp == 0x1A)
format = ColorFormat.colors16;
else if (bpp == 0x10 || bpp == 0x18)
format = ColorFormat.colors256;
br.BaseStream.Position = data_offset;
byte[] data = br.ReadBytes(data_size);
Encryption enc = new Encryption(data);
data = enc.Decrypt();
img = new RawImage(data, TileForm.Horizontal, format, width, height, false);
// Read palette
if ((bpp == 0x18 || bpp == 0x1A) && pluginHost.Get_Palette().Loaded)
pal = pluginHost.Get_Palette();
else
{
br.BaseStream.Position = pal_offset;
Color[] colors = Actions.BGR555ToColor(br.ReadBytes(pal_size));
pal = new RawPalette(new Color[][] { colors }, false, ColorFormat.colors16);
}
br.Close();
ismap = true;
Console.WriteLine("Image with bpp: {0}", bpp.ToString("x"));
}