Sha256: 175cffcebdad53b0bc52cf6bfb3de8748a9927a15d39a56bd9c95c2fcdc8c147

Contents?: true

Size: 625 Bytes

Versions: 9

Compression:

Stored size: 625 Bytes

Contents

require 'securerandom'

namespace :knapsack_pro do
  task :salt, [:size] do |_, args|
    default_size = 32
    size = (args[:size] || default_size).to_i

    if size >= default_size
      salt = SecureRandom.hex(size)
      puts 'Set environment variable on your CI server:'
      puts "KNAPSACK_PRO_SALT=#{salt}"
      puts
      puts "If you need longer salt you can provide the size:"
      puts "$ bundle exec rake knapsack_pro:salt[32]"
      puts "Default size 32 generates 64 chars."
    else
      puts "Salt must have at least 64 chars! You provided size #{size} which generates #{size*2} chars."
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
knapsack_pro-0.17.0 lib/tasks/salt.rake
knapsack_pro-0.16.0 lib/tasks/salt.rake
knapsack_pro-0.15.2 lib/tasks/salt.rake
knapsack_pro-0.15.1 lib/tasks/salt.rake
knapsack_pro-0.15.0 lib/tasks/salt.rake
knapsack_pro-0.14.0 lib/tasks/salt.rake
knapsack_pro-0.13.0 lib/tasks/salt.rake
knapsack_pro-0.12.0 lib/tasks/salt.rake
knapsack_pro-0.11.0 lib/tasks/salt.rake