示例#1
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);
            }
        }