Пример #1
0
        static void Main(string[] args)
        {
            // CSV Processor Test
            CSVProcessor          csvProcessor = new CSVProcessor(TestCSVFilePath);
            List <List <string> > stringTable  = csvProcessor.GetStringTable();
            List <Credential>     credentials  = csvProcessor.ParseCredentialsFromFile(CSVProcessor.CSVFileFormat.KeePass, stringTable).ToList();

            // JSON Processor Test
            JSONProcessor     jsonProcessor = new JSONProcessor(TestJSONFilePath);
            List <Credential> credentials1  = jsonProcessor.ParseCredentialsFromFile().ToList();
        }
Пример #2
0
        private void buttonImportFile_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = "C:\\";
                openFileDialog.Filter           = "Dashlane-Files (*.json)|*.json|KeePass-Files (*.csv)|*.csv";
                openFileDialog.FilterIndex      = 1;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    string            filePath      = openFileDialog.FileName;
                    List <Credential> userPasswords = new List <Credential>();

                    switch (openFileDialog.FilterIndex)
                    {
                    case 1:
                        JSONProcessor jsonProcessor = new JSONProcessor(filePath);
                        userPasswords = jsonProcessor.ParseCredentialsFromFile().ToList();
                        break;

                    case 2:
                        CSVProcessor csvProcessor = new CSVProcessor(filePath);
                        userPasswords = csvProcessor.
                                        ParseCredentialsFromFile(CSVProcessor.CSVFileFormat.KeePass, csvProcessor.GetStringTable()).ToList();
                        break;
                    }

                    if (userPasswords.Count == 0)
                    {
                        return;
                    }

                    foreach (Credential credential in userPasswords)
                    {
                        credentialQueue.Enqueue(credential);
                    }

                    byte[] command =
                    {
                        (byte)SerialCommandLimiter.COMM_BEGIN,
                        (byte)SerialCommand.COMM_GET_UNIQUE_ID,
                        (byte)SerialCommandLimiter.COMM_END
                    };
                    SerialSafeWrite(command, 3);
                }
            }
        }