I just wanted to add a little note because I was using this to figure out how to call the REST API for WooCommerce. I would recommend setting the line wrap to 0 to ensure the encode64 does not add a line break after 76 characters. I couldn’t figure out why I was getting a 400 bad request.
When I looked at the encoded key, I realized what was happening.