Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Encrypting/Decrypting files wirh ruby.

Reply
Thread Tools

Encrypting/Decrypting files wirh ruby.

 
 
Demetris Constantinou
Guest
Posts: n/a
 
      04-30-2010
I have been searching the internet to find a way to encrypt files and
then decrypt the back.. What I found is how to encrypt a string of text
and then decrypt it back.

For exampe you have a
plaintext = "some text"

you encrypt it into a ciphertext and then how to decrypt it back.

What I want to do is to encrypt a whole file, files like .doc, .docx,
xls, .pps and so on. Basically any file either this is a document, a
photo or whatever.

Any help on how to achieve this. I found a library 'ChilKat' but you
need to purchase a license to do this.

Any help is much appreciated!

Regards,
Demetris Constantinou
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Baduk Baduk
Guest
Posts: n/a
 
      05-01-2010
There are many examples of using OpenSSL to encrypt and decrypt files in
Ruby, which can be found via Google.

But why not just use OpenSSL straight from the command line?

Demetris Constantinou wrote:
> I have been searching the internet to find a way to encrypt files and
> then decrypt the back.. What I found is how to encrypt a string of text
> and then decrypt it back.
>
> For exampe you have a
> plaintext = "some text"
>
> you encrypt it into a ciphertext and then how to decrypt it back.
>
> What I want to do is to encrypt a whole file, files like .doc, .docx,
> .xls, .pps and so on. Basically any file either this is a document, a
> photo or whatever.
>
> Any help on how to achieve this. I found a library 'ChilKat' but you
> need to purchase a license to do this.
>
> Any help is much appreciated!
>
> Regards,
> Demetris Constantinou


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Demetris Constantinou
Guest
Posts: n/a
 
      05-01-2010
Baduk thanx for your reply.

I want to use it in a Rails application to encrypt the files and then
store them!


Baduk Baduk wrote:
> There are many examples of using OpenSSL to encrypt and decrypt files in
> Ruby, which can be found via Google.
>
> But why not just use OpenSSL straight from the command line?
>
> Demetris Constantinou wrote:
>> I have been searching the internet to find a way to encrypt files and
>> then decrypt the back.. What I found is how to encrypt a string of text
>> and then decrypt it back.
>>
>> For exampe you have a
>> plaintext = "some text"
>>
>> you encrypt it into a ciphertext and then how to decrypt it back.
>>
>> What I want to do is to encrypt a whole file, files like .doc, .docx,
>> .xls, .pps and so on. Basically any file either this is a document, a
>> photo or whatever.
>>
>> Any help on how to achieve this. I found a library 'ChilKat' but you
>> need to purchase a license to do this.
>>
>> Any help is much appreciated!
>>
>> Regards,
>> Demetris Constantinou


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Brian Candler
Guest
Posts: n/a
 
      05-02-2010
ruby's openssl library works fine, but it's quite low level, which means
that if you don't understand much about cryptography it's easy to write
an insecure application.

So if you're not an expert I'd suggest using gpg instead. Google "ruby
gpg" and "ruby gpgme" and you'll find plenty of examples.

I'd say the main weakness of your application is likely to be the key
storage. That is, if you keep your encryption keys in a file or in a
database, then anyone who breaks into your box will be able to decrypt
these encrypted files anyway, in which case the encryption is fairly
pointless.

You could make your app prompt for the key when it starts up and keep it
only in RAM. This can make it harder for an attacker to extract the key,
but it can be awkward to deploy in a Rails app if you are dynamically
starting worker processes.

Regards,

Brian.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
COM Server wirh MS Excel Cannonbiker Python 3 11-14-2009 02:15 PM
how i can extract text from the PDF files,power point files,Ms word files? crazyprakash Java 4 10-30-2005 10:17 AM
Text files read multiple files into single file, and then recreate the multiple files googlinggoogler@hotmail.com Python 4 02-13-2005 05:44 PM
sever application running only when compiled wirh jbuilder sm Java 0 03-06-2004 02:28 PM
Further problems wirh Emacs Python mode jblazi Python 0 01-12-2004 03:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57