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


C# Encryption.Decrypt方法代码示例

本文整理汇总了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();
 }
开发者ID:NotYours180,项目名称:Encryption,代码行数:9,代码来源:CaesarForm.cs

示例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);
        }
开发者ID:nordseth,项目名称:blog,代码行数:18,代码来源:EncryptionTest.cs

示例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("Данные введены неверно!");
     }
 }
开发者ID:NotYours180,项目名称:Encryption,代码行数:12,代码来源:CaesarForm.cs

示例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);
        }
开发者ID:schmuli,项目名称:AspNetClientSessions,代码行数:15,代码来源:EncryptionTests.cs

示例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);
        }
开发者ID:schmuli,项目名称:AspNetClientSessions,代码行数:15,代码来源:EncryptionTests.cs

示例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 "";
     }
 }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:16,代码来源:Encryption.cs

示例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();
            }
        }
开发者ID:nsbgamer,项目名称:NSBRTS,代码行数:24,代码来源:Program.cs

示例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;
        }
开发者ID:schmuli,项目名称:AspNetClientSessions,代码行数:29,代码来源:ClientSession.cs

示例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();
 }
开发者ID:NotYours180,项目名称:Encryption,代码行数:6,代码来源:TritemiusForm.cs

示例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);
        }
开发者ID:anndream,项目名称:anpr-1,代码行数:19,代码来源:Encryption.cs

示例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);

            }
开发者ID:compliashield,项目名称:certificate-issuer,代码行数:28,代码来源:UnitTest1.cs

示例12: btnDecrypt_Click

 private void btnDecrypt_Click(object sender, EventArgs e)
 {
     _encryption = new Gamma(rtbInput.Text, tbKey.Text);
     rtbOutput.Clear();
     rtbOutput.Text = _encryption.Decrypt();
 }
开发者ID:NotYours180,项目名称:Encryption,代码行数:6,代码来源:GammaForm.cs

示例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;
            }
        }
开发者ID:jeanfrancoisdrapeau,项目名称:ProScanAlert,代码行数:27,代码来源:Form1.cs

示例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;
        }
开发者ID:perryofpeek,项目名称:SqlToGraphite-core,代码行数:33,代码来源:BuilderBase.cs

示例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"));
        }
开发者ID:MetLob,项目名称:tinke,代码行数:51,代码来源:Images.cs


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