Skip to content

Instantly share code, notes, and snippets.

@JGallardo
Created December 13, 2012 03:03
Show Gist options
  • Save JGallardo/4273696 to your computer and use it in GitHub Desktop.
Save JGallardo/4273696 to your computer and use it in GitHub Desktop.
File decryption script written in Ruby
require 'crypt/blowfish'
unless ARGV[0]
puts "Usage: ruby decrypt.rb <Encrypted_filename.ext>"
puts "Example: ruby decrypt.rb" Encrypted_secret.stuff"
exit
end
filename = ARGV[0].chomp
puts "Decrypting #{filename}."
p = "Decrypted_#{filename}"
if File.exists?(p)
puts "File already exists."
exit
end
print 'Enter your encryption key: '
kee = gets.chomp
begin
blowfish = Crypt::Blowfish.new(kee)
blowfish.decrypt_file(filename.to_str, p)
puts 'Decryption SUCCESS!'
rescue Exception => e
puts "An error occurred during decryption: \n #{e}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment