public void SerializeData <T>(SecureStringOrArray password, T objectValue) { using (var stream = new MemoryStream()) using (var aes = CreateCrypto(password)) using (var cryptoStream = new CryptoStream(stream, aes.EncryptorTransform, CryptoStreamMode.Write)) { ServiceIo.WcfBinaryCompressedSerialize(cryptoStream, objectValue); cryptoStream.FlushFinalBlock(); _secureFileRepository.SaveDataFile(stream.ToArray(), false, -1, null); } }
public T DeserializeData <T>(SecureStringOrArray password) { //return AESBasedFileEncryption.WcfBinaryCompressedDeserializeEncrypted<T>(password); using (var stream = new MemoryStream(_secureFileRepository.GetDataFile())) using (var aes = CreateCrypto(password)) using (var cryptoStream = new CryptoStream( stream, aes.DecryptorTransform, CryptoStreamMode.Read)) { var result = ServiceIo.WcfBinaryCompressedDeserialize <T>(cryptoStream); return(result); } }