Ejemplo n.º 1
0
        public static async Task <String> GetPasswords(CryptographicKey AesKey)
        {
            CryptographicKey k = await GetRasKey(AesKey);

            String R = "";

            try
            {
                int a = int.Parse(await StorageInterface.ReadFromRoamingFolder("PWM/INDEX"));
                for (int i = 0; i < a; i++)
                {
                    IBuffer crypitic = await StorageInterface.ReadBufferFromRoamingFolder("PWM/Passwords" + i);

                    IBuffer plain = DecryptRsa(k, crypitic);
                    String  X     = CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf8, plain);
                    if (X == null)
                    {
                        X = "";
                    }
                    R += X;
                }
            }
            catch (Exception e)
            {
                e.PrintStackTrace();
                return("");
            }
            return(R);
        }
Ejemplo n.º 2
0
        public static async Task LoadAll()
        {
            String log = await StorageInterface.ReadFromRoamingFolder("BMW/log.log");

            String cfg = await StorageInterface.ReadFromRoamingFolder("BMW/cfg.cfg");

            String[] cfgs = cfg.Split("|");
            if (cfgs[0].Equals("IN"))
            {
                checkedIn = true;
            }
            msSinceEpoch = long.Parse(cfgs[1]);
        }
Ejemplo n.º 3
0
        public static async Task <Boolean> IsInitial()
        {
            String x;

            try
            {
                x = await StorageInterface.ReadFromRoamingFolder("PWM/Passwords0");
            }
            catch (ArgumentOutOfRangeException EX) //Non-Unicode zeichen in dem verschlüsselten text können nicht richtig interpretiert werden, das heist aber, dass die Datei existiert und schon was drinsteht => reicht aus für diese überprüfung
            {
                x = EX.Message;                    //Eigentlicher inhalt der datei wird durch einen garantiert korrekten String ersetzt, falls die ursprüngliche nachricht nicht als String gelesen werden kann.
                EX.PrintStackTrace();
            }
            Debug.WriteLine("HAVE READ");
            bool X = (x == null || x.Equals("")) ? true : false;//falls entweder irgendwas in der datei steht oder die datei zeichen enthält die nicht gelesen werden können (d.h. die date nicht leer ist true sonst false;)

            Debug.WriteLine(X);
            return(X);
        }
Ejemplo n.º 4
0
        public static async Task StorePasswords(String Passwords, CryptographicKey AesKey)
        {
            CryptographicKey k = await GetRasKey(AesKey);

            int a = int.Parse(await StorageInterface.ReadFromRoamingFolder("PWM/INDEX"));

            for (int i = 0; i < a; i++)
            {
                await StorageInterface.DeleteFromRoamingFolder("PWM/Passwords" + i);
            }


            String[] PWD = Passwords.DivideToLength(768);
            await StorageInterface.WriteToRoamingFolder("PWM/INDEX", PWD.Length.ToString());

            for (int i = 0; i < PWD.Length; i++)
            {
                IBuffer plain   = CryptographicBuffer.ConvertStringToBinary(PWD[i], BinaryStringEncoding.Utf8);
                IBuffer cryptic = CryptographicEngine.Encrypt(k, plain, null);
                await StorageInterface.WriteBufferToRoamingFolder("PWM/Passwords" + i, cryptic);
            }
        }
Ejemplo n.º 5
0
        private async Task Refresh()
        {
            String[] X = (await StorageInterface.ReadFromRoamingFolder("PoloTanken.csv")).Trim().Replace("\r", "|").Replace("\n", "|").Split("|");
            Double   km = 0, cost = 0, liter = 0;

            foreach (String A in X)
            {
                String[] S = A.Trim().Split(";");
                km    += Double.Parse(S[0]);
                liter += Double.Parse(S[1]);
                cost  += Double.Parse(S[2]);
            }
            TotalKmBox.Text    = km.ToString();
            TotalEuroBox.Text  = cost.ToString();
            TotalLiterBox.Text = liter.ToString();
            TotalAvgBox.Text   = (100 * liter / km).ToString();

            DateTime start     = new DateTime(2019, 11, 6, 15, 0, 0);
            DateTime now       = DateTime.Now;
            TimeSpan diff      = now - start;
            double   allowedKm = (KM * 12.0 * diff.TotalSeconds) / (24 * 3600 * MONTHS * 365.25);

            maxKmBox.Text = allowedKm.ToString();
        }
Ejemplo n.º 6
0
        private async void AddEntryButton_Click(object sender, RoutedEventArgs e)
        {
            await StorageInterface.WriteToRoamingFolder("PoloTanken.csv", await StorageInterface.ReadFromRoamingFolder("PoloTanken.csv") + "\r\n" + await InputTextDialogAsync("Neue Batankung"));

            await Refresh();
        }