示例#1
0
        public bool StartDecrypt()
        {
            using (FileStream input = new FileStream(_coreUML.MyPathEncrypt, FileMode.Open, FileAccess.ReadWrite))
            {
                using (StreamReader sReader = new StreamReader(input, Encoding.Default))
                {
                    _tmps     = sReader.ReadToEnd();
                    _tmpSplit = _tmps.Split('-');
                    _tmpkey   = new byte[_tmpSplit.Length];

                    _key = Encoding.Default.GetBytes(_coreUML.TmpKeyEncript);
                    for (int i = 0; i < _key.Length; i++)
                    {
                        _keyReady += _key[0];
                    }
                    for (int i = 0; i < _tmpSplit.Length; i++)
                    {
                        _tmpkey[i] = (byte)(Convert.ToInt32(_tmpSplit[i]) - _keyReady);
                    }
                }
            }

            SetMyPath path = new SetMyPath();

            path.MyPath();

            using (FileStream output = new FileStream(_coreUML.MyPath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                output.Write(_tmpkey, 0, _tmpkey.Length);
            }
            return(true);
        }
示例#2
0
        public bool StartEncrypt()
        {
            using (FileStream input = new FileStream(_coreUML.MyPathEncrypt, FileMode.Open, FileAccess.ReadWrite))
            {
                try
                {
                    using (StreamReader sReader = new StreamReader(input, Encoding.Default))
                    {
                        _tmps = sReader.ReadToEnd();
                        sReader.Close();
                    }
                }
                catch
                {
                    return(false);
                }
                input.Close();

                _key = Encoding.Default.GetBytes(_coreUML.TmpKeyEncript);
                for (int i = 0; i < _key.Length; i++)
                {
                    _keyReady += _key[0];
                }


                _tmpKey = new byte[_tmps.Length];
                _tmp    = new int[_tmpKey.Length];
                _tmpKey = Encoding.Default.GetBytes(_tmps);
                for (int i = 0; i < _tmp.Length; i++)
                {
                    _tmp[i] = _tmpKey[i] + _keyReady;
                }

                _tmps = "";
                for (int i = 0; i < _tmp.Length; i++)
                {
                    if (i != _tmp.Length - 1)
                    {
                        _tmps += _tmp[i] + "-";
                    }
                    else
                    {
                        _tmps += _tmp[i];
                    }
                }

                SetMyPath path = new SetMyPath();
                path.MyPathEncrypt();

                using (FileStream output = new FileStream(_coreUML.MyPathEncryptSave, FileMode.OpenOrCreate, FileAccess.ReadWrite))
                {
                    byte[] array = Encoding.Default.GetBytes(_tmps);
                    output.Write(array, 0, array.Length);
                    output.Close();
                }
                return(true);
            }
        }
示例#3
0
        public static bool SaveDate()
        {
            SetMyPath path = new SetMyPath();

            path.MyPath();
            Serialize serializer = new Serialize();

            serializer.SerializationDictionary();
            return(true);
        }
示例#4
0
 public void SaveImagePrepaire(bool isAs = false)
 {
     if (!isAs)
     {
         SetMyPath pathImage = new SetMyPath();
         pathImage.MyPathImage();
     }
     else
     {
         SetPathAs setPathAs = new SetPathAs();
         setPathAs.SetPathImage();
     }
     if (_coreUML.MyPathImage != "" && _coreUML.MyPathImage != null)
     {
         _coreUML.SaveImage();
         MessageBox.Show("Изображение сохранено");
     }
     else
     {
         MessageBox.Show("Не удалось сохранить изображение");
     }
 }