Day 20: Swift macOS password manager for people who hate the cloud
Tags: macos, swift, passwordmanager, cloud
Published: 2019-01-20 22:23:06

---
title: Day 20: Swift macOS password manager for people who hate the cloud
published: true
description: Follow along as I make a 100% cloudless and 100% native password manager for macOS. That's 200% raw password managing power.
tags: macos, swift, password manager, cloud
series: Making a swift MacOS password manager for people who hate the cloud
cover_image: https://thepracticaldev.s3.amazonaws.com/i/q6r73zbfbm3mpfs98bu5.jpg
---

[<- For Day 19 go here](https://dev.to/swlkr/day-19-swift-macos-password-manager-for-people-who-hate-the-cloud-283f)

📅 01/20/2019
🚀 10 days until launch
🔥 19 day streak
💰 $2.99 price
🤑 $0 revenue
📈 0 customers
⌚️ 30 hours spent
💻 82 files changed, 247751 insertions(+), 545 deletions(-)
🏁 Today's goal: **Parse favicons from websites**

**3:16 PM**
Late start again! Sunday evening coding! Let's get to it. Oh wait, I wanted to take a moment to talk about the overall architecture and how it actually keeps your passwords safe.

So there are two things that work together to make this thing a cloudless reality.

__1 Keychain__

I know that the keychain can be synced with the cloud, and that's your choice, but there isn't really a better place to store sensitive stuff. My options were pretty much keychain or NSUserDefaults, I chose to keep the master password in the keychain. So how this works is that the login password to your computer protects the keychain, which in turn protects your master password.

__2 SQLite with [SQLcipher](https://github.com/sqlcipher/sqlcipher)__

So this is an encrypted file (well encrypted set of files) that is read by SQLite.swift and passed the key (your master password) in plaintext, luckily this is a desktop app, not a web app, so plaintext isn't that bad!

Every line of code I've written on top of these two things are pretty much just icing on the cake, hopefully that icing is worth some $$, if not, that's ok too. It's nice knowing that I'm in control of the code that stores all of my passwords ✊ and anyone can audit that code when I open up the source!

**3:21 PM**
OK, now that that's over with, let's go. Today is general design clean up and parsing favicons from the websites for each login.

**7:02 PM**
Sucked into netflix, I cancelled it though, so that's good. Favicons from websites oh and bring back the password generator.

**7:54 PM**
Hey! Brought back the password generator, also that NSUserTemplate icon for every password, amazing

![](https://thepracticaldev.s3.amazonaws.com/i/e8e0pr4ybka6lnx0tx7w.png)

**8:02 PM**
I found this library to parse favicons/touch icons with swift [leonbreedt/FavIcon](https://github.com/leonbreedt/FavIcon) he seems trustworthy, also looked at the code for a few minutes, LGTM! Trust is not earned on the internet, ITS GIVEN!

**9:42 PM**
While watching a documentary about how bad teflon (PFOA/C-8) is, I got the image stuff kind of working! Hurray! I'll have to fix it though because apple's icon is a rectangle somehow while google's is a favicon and blurry. Not cool. Here's some code!

How to write an NSImage to disk

```swift
extension NSImage {
    func write(to url: URL, fileType: NSBitmapImageRep.FileType, options: Data.WritingOptions = .atomic) -> Bool {
        do {
            if let bits = representations.first as? NSBitmapImageRep {
                let data = bits.representation(using: fileType, properties: [:])
                try data?.write(to: url, options: options)
            }
            return true
        } catch {
            print(error)
            return false
        }
    }
}
```

And a screenshot!

![](https://thepracticaldev.s3.amazonaws.com/i/cln7w1ua7kztnej1zkz2.png)

That's today's goal, done and done. See you tomorrow 👋