DecryptData() публичный Метод

Takes in a byte array and returns the data in a unencrypted format.
public DecryptData ( byte EncryptedData ) : byte[]
EncryptedData byte The data to decrypt.
Результат byte[]
Пример #1
0
        ///<summary>Decrypts the packet given a SymmetricEncryption returning true
        ///if it was able to decrypt it.</summary>
        public bool Decrypt(SymmetricEncryption se)
        {
            byte[] decrypted = se.DecryptData(_encrypted_data);
            int    pos       = 0;
            int    data_len  = NumberSerializer.ReadInt(decrypted, pos);

            pos       += 4;
            _data      = MemBlock.Reference(decrypted, pos, data_len);
            pos       += data_len;
            _signature = MemBlock.Reference(decrypted, pos, decrypted.Length - pos);
            return(true);
        }
Пример #2
0
        public void TDES()
        {
            SymmetricEncryption enc = new SymmetricEncryption(new TripleDESCryptoServiceProvider());

            for (int i = 1000; i < 1025; i++)
            {
                byte[] data = new byte[1010];
                RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
                rng.GetBytes(data);
                byte[] encd = enc.EncryptData(data);
                if (i % 12 == 0)
                {
                    continue;
                }
                byte[] decd = enc.DecryptData(encd);
                Brunet.Util.MemBlock mdecd = Brunet.Util.MemBlock.Reference(decd);
                Brunet.Util.MemBlock mdata = Brunet.Util.MemBlock.Reference(data);
                Assert.AreEqual(mdecd, mdata, "TDESEncryption: " + i);
            }
        }