hpg in Elm

Some of you are already familiar with one of my little side projects, hpg. hpg started as a little command line tool for generating strong passwords. It works quite well when you have a computer at hand with it installed.

However, I often find myself away from my laptop and in need of one of my generated passwords. Sometimes I can get them from my browser's password manager, but often that option isn't available. In that case, having a globally accessible hpg would be a big help - so I wrote a version that runs in the browser.


This version of hpg has the same goals as the original:

  • passwords are generated on the fly, based on an identifier paired with a salt/master password;
  • the passwords themselves aren't stored;
  • any password you generate can be re-generated from the same inputs (the passwords are deterministic);
  • default settings generate very strong passwords.

Because there's no database, if you remember the identifier (maybe a website name?) and your salt password you can recreate the generated password from any hpg installation, including the new web one.

If you want to check it out, you can find it here.

So why Elm? Well, I have a love-hate (mostly hate) relationship with Javascript. It runs in the browser, which is nice; it has lots of libraries, which is nice; but it also has no real support for verifying your program's correctness, which sucks. I also hate DOM programming and I've had bad experiences with AngularJS in the past. Elm has a much better story as a strongly typed functional language with strong support for writing web applications.

Unfortunately it's not all unicorns and rainbows. Elm's focus on safety means that there's no clean way to do interop with Javascript functions, even if they're pure. Instead you have to go out to JS-land via "ports", passing values back and forth across the wall. This constraint requires the Elm variant of HPG to offload most of the "interesting" logic to a pure Javascript function anyway, which is rather disappointing. This is one of the big reasons that I'm interested in learning Purescript.

If you're curious about the code, it lives in the main hpg repo along with the Python implementation.