Skip to content

Instantly share code, notes, and snippets.

@Ninjex
Ninjex / gist:9048279
Last active August 29, 2015 13:56 — forked from Amazingred/gist:4104717
#!/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
Ninjex / lookup.rb
Last active August 29, 2015 13:56
MD5 Lookup Table Generator
#!/usr/bin/ruby
require 'digest/md5' # Hashing strings to MD5
if ARGV[0] != '-i' || ARGV[2] != '-o' || ARGV[3].nil?
puts "Syntax Error!"
puts "Usage: ruby lookup.rb -i <input file> -o <output file>"
else
input_file = ARGV[1]
if File.exist?(input_file)
output_file = ARGV[3]
text = File.open(input_file).read