Skip to content

Instantly share code, notes, and snippets.

@Ninjex
Forked from Amazingred/gist:4104717
Last active August 29, 2015 13:56
Show Gist options
  • Save Ninjex/9048279 to your computer and use it in GitHub Desktop.
Save Ninjex/9048279 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Ruby script to generate SSHA (Good for LDAP)
require 'digest/sha1'
require 'base64'
# The output in hash will never have trailing whitespace, removed .chomp!
hash = Base64.encode64(Digest::SHA1.digest(#{pass}#{salt}#{salt}))
# Use string interpolation, no need to add \n puts does this for you
puts "userPassword: #{hash}"
@Ninjex
Copy link
Author

Ninjex commented Feb 17, 2014

The output for hash will not have trailing whitespace, so there is no need for .chomp!
Use string interpolation not the + method. Also, there is no need for \n since puts does this by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment