예제 #1
0
        private void add(string username, string password)
        {
            byte[]        pass  = Encoding.ASCII.GetBytes(password);
            HMACSHA512    hmac1 = new HMACSHA512(new byte[] { 0xBA, 0x43, 0xB7, 0x3E, 0xCB });
            StringBuilder sb    = new StringBuilder();

            byte[] passHash = hmac1.ComputeHash(pass);
            foreach (byte b in passHash)
            {
                sb.Append((char)b);
            }
            Properties.Settings.Default.Password = sb.ToString();
            sb.Clear();
            HMACSHA384 hmac2 = new HMACSHA384(passHash);

            byte[] key = hmac2.ComputeHash(pass);
            for (int i = 0; i < username.Length; i++)
            {
                sb.Append((char)((byte)username[i] ^ key[i % key.Length]));
            }
            Properties.Settings.Default.Username = sb.ToString();
            Properties.Settings.Default.Save();

            ContentFile.Encrypt(password);
            MessageBox.Show("Registered your user!");
            Paging.LoadPage(Pages.Login);
        }
예제 #2
0
        private void window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Logging.Write("Closing application", "UI", LogLevel.Info);

            saveTimer.Stop();
            if (ContentFile.CheckValidity()) //If the ContentFile is decrypted, attempt to save data
            {
                ContentFile.SaveData();      //TODO - DISCREPENCY IN UNENCRYPTED SAVING. ENSURE THE ARCHIVE IS ACTUALLY OPEN!!
                if (Login.Password != null)
                {
                    ContentFile.Encrypt(Login.Password);   //Encrypt the data
                }
            }
        }