EncryptData() public static method

public static EncryptData ( byte plainByteData ) : byte[]
plainByteData byte
return byte[]
コード例 #1
0
ファイル: Utils.cs プロジェクト: iamapi/MtgoxTrader
        public static void SaveToFile(object t, string fileName)
        {
            try
            {
                using (MemoryStream memStream = new MemoryStream())
                {
                    DataContractSerializer serializer = new DataContractSerializer(t.GetType());
                    //foreach (StopOrder order in orderList)
                    {
                        serializer.WriteObject(memStream, t);
                    }

                    // Encrypt the memory stream.
                    byte[] encryptedData = Encryption.EncryptData(memStream.ToArray());

                    // Write encrypted credentials to the file and ACL the file simultaneously.
                    using (FileStream stream =
                               new FileStream(fileName, FileMode.Create))
                    {
                        stream.Write(encryptedData, 0, encryptedData.Length);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #2
0
        public static void SaveToFile(Config config, string fileName)
        {
            using (MemoryStream memStream = new MemoryStream())
            {
                DataContractSerializer serializer = new DataContractSerializer(typeof(Config));
                serializer.WriteObject(memStream, config);

                // Encrypt the memory stream.
                byte[] encryptedData = Encryption.EncryptData(memStream.ToArray());

                using (FileStream stream =
                           new FileStream(fileName, FileMode.Create))
                {
                    stream.Write(encryptedData, 0, encryptedData.Length);
                }
            }
        }