Sha256: f7bae558079b87f384f5695f8a2bec71a402e8a0bde0c75f70001368d04b08f9

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

namespace :symmetric_encryption do

  desc 'Decrypt the supplied string. Example: VALUE="_encrypted_string_" rake symmetric_encryption:decrypt'
  task :decrypt => :environment do
    puts "\nEncrypted: #{ENV['VALUE']}"
    puts "Decrypted: #{SymmetricEncryption.decrypt(ENV['VALUE'])}\n\n"
  end

  desc 'Encrypt a value, such as a password. Example: rake symmetric_encryption:encrypt'
  task :encrypt => :environment do
    require 'highline'
    password1 = nil
    password2 = 0

    while password1 != password2
      password1 = HighLine.new.ask("Enter the value to encrypt:") { |q| q.echo = "*" }
      password2 = HighLine.new.ask("Re-enter the value to encrypt:") { |q| q.echo = "*" }

      if (password1 != password2)
        puts "Passwords do not match, please try again"
      end
    end
    puts "\nEncrypted: #{SymmetricEncryption.encrypt(password1)}\n\n"
  end

  desc 'Generate a random password and display its encrypted form. Example: rake symmetric_encryption:random_password'
  task :random_password => :environment do
    p = SymmetricEncryption.random_password
    puts "\nGenerated Password: #{p}"
    puts "Encrypted: #{SymmetricEncryption.encrypt(p)}\n\n"
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
symmetric-encryption-1.0.0 lib/symmetric_encryption/railties/symmetric_encryption.rake
symmetric-encryption-0.9.1 lib/symmetric_encryption/railties/symmetric_encryption.rake
symmetric-encryption-0.9.0 lib/symmetric_encryption/railties/symmetric_encryption.rake
symmetric-encryption-0.8.0 lib/symmetric_encryption/railties/symmetric_encryption.rake