Exemplo n.º 1
0
		public void SaveUser(User user)
		{
			//Create new file
			FileStream fs=new FileStream(GetFilename(user.UserName), FileMode.Create);
			//Fire-up crypto to secure file
			DES cryptoalgorithm = DES.Create();
			CryptoStream encStream = new CryptoStream(fs, cryptoalgorithm.CreateEncryptor(Key, IV), CryptoStreamMode.Write);
			//Serialize user into encrypted file
			XmlSerializer serializer=new XmlSerializer(user.GetType());
			serializer.Serialize(encStream, user);
			encStream.Close();
			fs.Close();
		}
Exemplo n.º 2
0
        public void SaveUser(User user)
        {
            //Create new file
            FileStream fs = new FileStream(GetFilename(user.UserName), FileMode.Create);
            //Fire-up crypto to secure file
            DES          cryptoalgorithm = DES.Create();
            CryptoStream encStream       = new CryptoStream(fs, cryptoalgorithm.CreateEncryptor(Key, IV), CryptoStreamMode.Write);
            //Serialize user into encrypted file
            XmlSerializer serializer = new XmlSerializer(user.GetType());

            serializer.Serialize(encStream, user);
            encStream.Close();
            fs.Close();
        }