Decrypt a File

Decrypt a File

decrypt.rb

This code is structured much like the encryption algorithm, so I will focus on the differences between the two. I am using the same algorithm for decryption as used during encryption. As mentioned earlier, you can use any number of encryption algorithms—just be sure to use the corresponding decryption algorithm. Don't forget your password, or else you will have to write your own brute force script if you ever want to see your data again!

The Code

 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 ...

Get Wicked Cool Ruby Scripts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.