public byte[] Decrypt(CipherIVPair pair)
 {
     using var cipherStream = new MemoryStream(pair.Cipher);
     using var stream       = new MemoryStream();
     Decrypt(cipherStream, stream, pair.IV);
     return(stream.ToArray());
 }
Example #2
0
        public virtual CipherIVPair Separate(byte[] bytes)
        {
            var pair = new CipherIVPair
            {
                Cipher = bytes.Slice(0, -8),
                IV     = bytes.Slice(-8),
            };

            return(pair);
        }
        public CipherIVPair Encrypt(byte[] data)
        {
            using var stream       = new MemoryStream(data);
            using var cipherStream = new MemoryStream();
            Encrypt(stream, cipherStream, out var iv);

            var pair = new CipherIVPair
            {
                Cipher = cipherStream.ToArray(),
                IV     = iv,
            };

            return(pair);
        }
Example #4
0
 public virtual byte[] Combine(CipherIVPair pair)
 {
     return(pair.Cipher.Concat(pair.IV).ToArray());
 }