Ejemplo n.º 1
0
        public static T Decrypt <T>(string filePath, string keyFile)
        {
            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException(string.Format("The file specied to deserialize from {0} does not exist", filePath));
            }

            if (!File.Exists(keyFile))
            {
                throw new FileNotFoundException(string.Format("The key file specified {0} does not exist", keyFile));
            }

            KeyVectorPair key = KeyVectorPair.Load(keyFile); //Serialization.Deserialize<Base64EncodedRijndaelKeyVectorPair>(keyFile);

            using (StreamReader sr = new StreamReader(filePath))
            {
                string text = sr.ReadToEnd();
                return(Deserialize <T>(text, key));
            }
        }