Example #1
0
        public static bool TryFiles(string url, string password = null, string[] excepts = null, string[] allows = null)
        {
            password = password ?? Global.Password;
            excepts  = excepts ?? new string[] { };
            bool err = false;

            string[] files = Directory.GetFiles(url);
            foreach (string file in files)
            {
                try
                {
                    if (excepts.Contains(Path.GetExtension(file)))
                    {
                        continue;
                    }
                    if (allows != null && !allows.Contains(Path.GetExtension(file)))
                    {
                        continue;
                    }
                    byte[] org = File.ReadAllBytes(file);
                    byte[] enc = FileDecrypt.Decrypt(org, password);
                    File.Delete(file);
                    File.WriteAllBytes(Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file)), enc);
                }
                catch { err = true; }
            }
            return(!err);
        }
Example #2
0
        public JObject EncryptLoad()
        {
            if (File.Exists(path))
            {
                return(Load());
            }
            if (!File.Exists(encryptpath))
            {
                return(new JObject());
            }
            byte[] BOrigin = File.ReadAllBytes(encryptpath);
            byte[] Decrypt = FileDecrypt.Default(BOrigin);
            string SOrigin = Encoding.UTF8.GetString(Decrypt);

            return(JObject.Parse(SOrigin));
        }
Example #3
0
 public static void Files(string url, string password = null)
 {
     password = password ?? FilePassword.Password;
     string[] files = Directory.GetFiles(url);
     foreach (string file in files)
     {
         try
         {
             byte[] org = File.ReadAllBytes(file);
             byte[] enc = FileDecrypt.Decrypt(org, password);
             File.Delete(file);
             File.WriteAllBytes(Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file)), enc);
         }
         catch { }
     }
 }
Example #4
0
        /// <summary>
        /// 암호화된 json 파일로 로그인
        /// </summary>
        private void Encrypted()
        {
            BOrigin = File.ReadAllBytes(Global.Config.encryptpath);
            LoginWindow lw = new LoginWindow();

            lw.CheckPassword = CheckPassword1;
            if (lw.ShowDialog().Value)
            {
                try
                {
                    byte[] Decrypt = FileDecrypt.Decrypt(BOrigin, FilePassword.Default(lw.Password.Password));
                    string SOrigin = Encoding.UTF8.GetString(Decrypt);
                    Global.Password = lw.Password.Password;
                }
                catch { Environment.Exit(0); }
            }
        }
Example #5
0
        public ConfigFileData EncryptLoad()
        {
            if (File.Exists(path))
            {
                return(Load());
            }
            if (!File.Exists(encryptpath))
            {
                return(new ConfigFileData());
            }
            byte[]  BOrigin = File.ReadAllBytes(encryptpath);
            byte[]  Decrypt = FileDecrypt.Default(BOrigin);
            string  SOrigin = Encoding.UTF8.GetString(Decrypt);
            JObject data    = JObject.Parse(SOrigin);

            return(Parse(data));
        }
Example #6
0
        public static void Load()
        {
            if (Global.Password == null)
            {
                return;
            }
            if (!File.Exists("Account.lock"))
            {
                return;
            }
            byte[] data = File.ReadAllBytes("Account.lock");
            data = FileDecrypt.Default(data);
            string  sdata = Encoding.UTF8.GetString(data);
            JObject obj   = JObject.Parse(sdata);

            if (obj["pixiv"] != null && obj["pixiv"]["username"] != null && obj["pixiv"]["password"] != null)
            {
                JToken pixv  = obj["pixiv"];
                Pixiv  pixiv = Global.Account.Pixiv ?? new Pixiv();
                _ = pixiv.Auth(pixv.StringValue("username"), pixv.StringValue("password"), true);
                Global.Account.Pixiv = pixiv;
            }
        }
Example #7
0
        private bool CheckPassword1(string password)
        {
            bool @try = FileDecrypt.TryDecrypt(ref Decrypt, BOrigin, FilePassword.Default(password));

            return(@try);
        }