# Encrypting files in Ruby

**URL:** <https://www.ruby-forum.com/t/encrypting-files-in-ruby/187824>\
**Category:** Ruby\
**Created:** [April 30, 2010, 12:00am UTC](https://www.ruby-forum.com/t/encrypting-files-in-ruby/187824 "2010-04-30T00:00:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![demec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f05b48/32.png) [@demec](https://www.ruby-forum.com/u/demec)\
**Post date:** [April 30, 2010, 12:00am UTC](https://www.ruby-forum.com/t/encrypting-files-in-ruby/187824/1 "2010-04-30T00:00:41Z")

</div>

So far the tutorials I’ve seen are for encrypting text and then  
decrypting it back.  
So for example you have a  
plaintext = “some text”

you encrypt it and the you decrypt it depending on how you encrypted  
it.

What I am looking for is to encrypt a whole file and then store it.  
for example I allow my users to upload .doc/.xls files in a Rails app.  
I want to encrypt those files so I would not store them like that, and  
in case a user wants to download it back the app will decrypt it and  
then send it to user.

How can I do this ?

---

<div class="post-metadata">

**Author:** ![demec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f05b48/32.png) [@demec](https://www.ruby-forum.com/u/demec)\
**Post date:** [April 30, 2010, 9:57am UTC](https://www.ruby-forum.com/t/encrypting-files-in-ruby/187824/2 "2010-04-30T09:57:40Z")

</div>

On Apr 29, 11:58 pm, Demec [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want to encrypt those files so I would not store them like that, and  
> in case a user wants to download it back the app will decrypt it and  
> then send it to user.
> 
> How can I do this ?

Try [ruby encrypt decrypt - Google Search](http://www.google.com/search?q=ruby+encrypt+decrypt)
