I made a simple Bcrypt hash generator website with Golang

Sometimes when I am working with dummy database I might need to change the password of a generated user. The easiest way to do this is to got to google for a bcrypt generator and then paste the generated hash into the database in order to update the password. This is much quicker than having to write a function to do this for me or to create a new user from scratch. It is also useful if I need to reset a password to an account which I have totally lost access to. Turns out I don’t like many of the bcrypt generators that are out there and the domain bcrypt.fun was available so I figured, why not make my own generator since I already created password.fun.

So in one afternoon I sat down, copied most of the code I had used for password.fun and created this new website. The website uses the Revel framework which feels overkill for a small website like this. I also have no frontend design skills. I just went with the old standard bootstrap layout which looks alright. Now that the site is done you are able to paste in one or more strings (one per line) which will turn into a bcrypt hash when you hit generate. That’s all that it really does, so simple. It does have an API which is technically open to anyone to use but I skipped the documentation and FAQ sections for this project as it was probably overkill for the password generator anyways. There is also no mailchimp sign up form, why did I even add that to the password site?

Deploying Bcrypt.fun

Once again I would like to mention that this is all hosted with Caddy. Caddy makes the setup super simple compared to Nginx or Apache that I used to use in the past. The configuration is literally 4 lines which includes the SSL configuration, see below:

www.bcrypt.fun, bcrypt.fun {
    tls markus@tenghamn.com
    proxy / localhost:8005
}

As always, you can find the entire source code for Bcrypt.fun on Github.

Switching From Nginx To Caddy

I am a long time user of Apache, it was the first web server software I learned to use and therefore it felt like a no brainer to always use it. However over the past year I have started using Nginx more and more. It felt foreign at first but once you get a hang of how to configure new hosts and do the initial setup it’s really just as easy to use as Apache and in my current opinion, much better when it comes to memory usage and the amount of requests it can handle. If you want to read more about the differences you can read this post from tutsplus that describes the pros and cons of using either one for a wordpress website (generally the things discussed here applies to most other applications).

There you have some background information, so what’s Caddy and why should I switch to it? Caddy is written in go and is much easier to use compared to Nginx or Apache but I would not claim that it’s better than either of these. There is a pretty good article describing the differences of Nginx and Caddy here. So why use it? Well with Nginx I have the main configuration file and an additional host file. Here is a full example configuration from the Nginx docs.

So let’s take a look at Caddy, here is what my config file might look like if I was setting up a Laravel website.

example.com {
    root ./public
    fastcgi / 127.0.0.1:9000 php
    rewrite {
        to {path} {path}/ /index.php?{query}
    }
}

That’s it. That’s all the configuration I need to write to get my Laravel site up and running. If I want to add another host on my Caddy server I can simply add another host under this one with the same structure.

The best part is you can automatically download, verify and configure ssl certificates from Let’s Encrypt for any domain as long as the domain already points to your server.

Caddy is written in go and supports plugins. To install plugins simply download the Caddy source and import your plugins, you can find a list of plugins on the Caddy forums.