/// <summary>
        /// Generate a new crypto configuration and serializes the output
        /// to <paramref name="stream"/>.
        /// </summary>
        /// <param name="stream">The stream to serialize the output to.</param>
        public void GenerateNewCryptoConfiguration(Stream stream)
        {
            RijndaelSymmetricCryptoConfiguration cryptoConfiguration = new RijndaelSymmetricCryptoConfiguration();
            RandomString generator = new RandomString();
            cryptoConfiguration.Password = generator.NextXml(16);
            cryptoConfiguration.RgbInitVector = generator.NextXml(16);
            cryptoConfiguration.SaltValue = generator.NextXml(16);

            using (XmlWriter writer = XmlWriter.Create(stream, new XmlWriterSettings { Indent = true, IndentChars = "    " }))
            {
                new XmlSerializer(cryptoConfiguration.GetType()).Serialize(writer, cryptoConfiguration);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SessionData"/> class.
 /// </summary>
 public SessionData()
 {
     RandomString random = new RandomString();
     this.SessionId = random.Next(40, true, true, true, false);
     this.SessionStarted = DateTime.Now;
 }