Skip to content

Instantly share code, notes, and snippets.

@ToQoz
Last active July 3, 2018 08:46
Embed
What would you like to do?
#!/usr/bin/env ruby
# Usage
# $ htpasswd.rb 'your_usrename', 'your_password'
# UseCase
# Generate htpasswd for nginx without apache tools.
require "base64"
username, password = ARGV
salt = Base64.encode64((("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a).shuffle[0..7].join)
puts "#{username}:#{password.crypt(salt)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment