Skip to content

Instantly share code, notes, and snippets.

@tylerpace
Last active August 23, 2024 08:27
Show Gist options
  • Save tylerpace/8f64b7e00ffd9fb1ef5ea70df0f9442f to your computer and use it in GitHub Desktop.
Save tylerpace/8f64b7e00ffd9fb1ef5ea70df0f9442f to your computer and use it in GitHub Desktop.
PBKDF2 SHA-512 Ruby script for creating Mac OS >= 10.7 password parameters that Puppet can manage
#!/usr/bin/env ruby
require 'openssl'
puts "enter the password that you would like to hash:\n"
password = gets
password = password.chomp
salt = OpenSSL::Random.random_bytes(32)
iterations = 40_000
digest = OpenSSL::Digest::SHA512.new
hash = OpenSSL::PKCS5.pbkdf2_hmac(password, salt, iterations, 128, digest)
puts "\nhere's the PBKDF2 SHA-512 details for the supplied password:\n\n"
puts "password => '#{hash.unpack('H*').first}',"
puts "salt => '#{salt.unpack('H*').first}',"
puts "iterations => #{iterations}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment