Exemplo n.º 1
0
        public string GetFileString(string filePath, string passWordCertificate)
        {
            if (System.IO.File.Exists(filePath))
            {
                using (System.IO.StreamReader sw = new System.IO.StreamReader(filePath))
                {
                    string dbString = sw.ReadToEnd();

                    //判断行头是否此账号下的内容
                    if (!dbString.StartsWith(passWordCertificate))
                    {
                        throw new NullReferenceException("数据文件被修改或者配置错误");
                    }
                    string db  = dbString.Substring(0, dbString.Length - 32);
                    string md5 = dbString.Replace(db, "");
                    EncryptAndDecodeServer.IEncryptAndDecodeServer encrypt = new EncryptAndDecodeServer.EncryptAndDecodeServer();
                    if (md5 == encrypt.GetMd532(db))
                    {
                        return(db.Replace(passWordCertificate, ""));
                    }
                    else
                    {
                        throw new NullReferenceException("数据文件被修改或者配置错误");
                    }
                }
            }
            else
            {
                throw new NullReferenceException("数据文件未查找到");
            }
        }
Exemplo n.º 2
0
        //private log4net.ILog _log = log4net.LogManager.GetLogger("PassWordBooks");
        public MainWindow()
        {
            InitializeComponent();
            string str = "{'张志超':'你妈妈','data':[{},{}]}", key = "04551df76713561574a6183f050503bd", re = string.Empty, re1 = string.Empty;

            EncryptAndDecodeServer.IEncryptAndDecodeServer i = new EncryptAndDecodeServer.EncryptAndDecodeServer();
            re  = i.AesEncryption(str, key);
            re1 = i.AesDecryption(re, key);
        }
Exemplo n.º 3
0
 public void SaveFile(string fileString, string passWordCertificate, string filePath)
 {
     using (System.IO.StreamWriter sw = new System.IO.StreamWriter(filePath, false))
     {
         EncryptAndDecodeServer.IEncryptAndDecodeServer encrypt = new EncryptAndDecodeServer.EncryptAndDecodeServer();
         string md5 = encrypt.GetMd532(passWordCertificate + fileString);
         sw.Write((passWordCertificate + fileString + md5).ToCharArray());
     }
 }
Exemplo n.º 4
0
        public void SavePhysicsKey(string fileDir, string passWordSecurity, string secondPassWord, string target)
        {
            EncryptAndDecodeServer.IEncryptAndDecodeServer server = new EncryptAndDecodeServer.EncryptAndDecodeServer();
            string physiceStr = server.AesEncryption(secondPassWord, passWordSecurity);
            string filePath   = string.Format(@"{0}/{1}_{2}.db", fileDir.TrimEnd('/'), target, DateTime.Now.ToString("yyyyMMddhhmmss"));

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(filePath))
            {
                sw.WriteLine(physiceStr);
            }
        }
Exemplo n.º 5
0
 public string GetPhysicsKey(string filePath, string passWordSecurity)
 {
     if (System.IO.File.Exists(filePath))
     {
         throw new NullReferenceException("物理文件密钥未查询到");
     }
     EncryptAndDecodeServer.IEncryptAndDecodeServer server = new EncryptAndDecodeServer.EncryptAndDecodeServer();
     using (System.IO.StreamReader sw = new System.IO.StreamReader(filePath))
     {
         string str = sw.ReadToEnd();
         str = server.AesDecryption(str, passWordSecurity);
         return(str);
     }
 }