DEV Community

Cover image for Day 20: Swift macOS password manager for people who hate the cloud
Sean Walker
Sean Walker

Posted on

Day 20: Swift macOS password manager for people who hate the cloud

<- For Day 19 go here

📅 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

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

8:02 PM
I found this library to parse favicons/touch icons with swift 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

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 {
            return false

And a screenshot!

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

Top comments (0)