public static Dictionary <string, string> DecryptProfile(byte[] encrypted)
        {
            var decrypted = AesEcb.Decrypt(Key, encrypted);
            var encoded   = PaddingUtil.RemovePad(decrypted);
            var decoded   = KvpParser.Decode(System.Text.Encoding.ASCII.GetString(encoded));

            return(decoded);
        }
Esempio n. 2
0
        public static byte[] Decrypt(byte[] key, byte[] iv, byte[] data, bool removePadding = true)
        {
            var blocks        = data.Chunks(BlockSizeBytes);
            var clearText     = new byte[data.Length];
            int index         = 0;
            var previousBlock = iv;

            foreach (var block in blocks)
            {
                var blockArray = block.ToArray();
                var decrypted  = AesEcb.Decrypt(key, blockArray);
                var xord       = XorUtil.Xor(decrypted, previousBlock);
                Array.Copy(xord, 0, clearText, index, BlockSizeBytes);
                previousBlock = blockArray;
                index        += BlockSizeBytes;
            }
            if (removePadding)
            {
                return(PaddingUtil.RemovePad(clearText));
            }
            return(clearText);
        }