예제 #1
0
        public static T1 WcfBinaryCompressedDeserializeEncrypted <T1>(String dataFileName, SecureStringOrArray password)
        {
            var dataFilePath = GetDataFilePath(dataFileName);

            using (var stream = File.Open(dataFilePath, FileMode.Open))
                using (var aes = CreateCrypto(password, dataFileName))
                    using (var cryptoStream = new CryptoStream(
                               stream,
                               aes.DecryptorTransform,
                               CryptoStreamMode.Read))
                    {
                        var result = ServiceIo.WcfBinaryCompressedDeserialize <T1>(cryptoStream);
                        return(result);
                    }
        }
예제 #2
0
        public static void WcfBinaryCompressedSerializeEncrypted <T1>(String dataFileName, SecureStringOrArray password, T1 objectValue)
        {
            SetupDataName(dataFileName);
            String dataFilePath     = GetDataFilePath(dataFileName);
            String tempDataFilePath = SwapExtension(dataFilePath, ".tmp");

            using (var stream = File.Open(tempDataFilePath, FileMode.Create))
                using (DisposableAes aes = CreateCrypto(password, dataFileName))
                    using (CryptoStream cryptoStream = new CryptoStream(
                               stream,
                               aes.EncryptorTransform,
                               CryptoStreamMode.Write))
                    {
                        ServiceIo.WcfBinaryCompressedSerialize(cryptoStream, objectValue);
                    }
            SafeFileMove(dataFilePath, tempDataFilePath);
        }