Skip to content

Instantly share code, notes, and snippets.

@ToQoz
Last active July 3, 2018 08:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToQoz/4600779 to your computer and use it in GitHub Desktop.
Save ToQoz/4600779 to your computer and use it in GitHub Desktop.
#!/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