V
Venkat Bagam
Hi Folks,
Yesterday, in my ruby application, I was needed to
encrypt/decrypt a file. I searched for a 2-way encryption technique and
ended up with ezcrypto gem. I thought to give it a test. I was able to
encrypt the content and store it in a file but getting errors while
decrypting the file content and writing to console. I couldn't figure
out the problem. here is my code
require 'rubygems'
require 'ezcrypto'
@key = EzCrypto::Key.with_password "private documents","salted hash"
file1 = File.new("crypto.txt", "w")
@encrypted = @key.encrypt "These are private documents"
file1.puts @encrypted
file1.close
puts "Here is the content"
file2 = File.read("crypto.txt")
puts @key.decrypt file2
Can anyone figure out the problem? or suggest me a different crypting
technique other than ezcrypto or suggest me a ruby app implementing such
a requirement..
or a code snippet
any help appreciated
thanks®ards,
Venkat
Attachments:
http://www.ruby-forum.com/attachment/304/test.rb
Yesterday, in my ruby application, I was needed to
encrypt/decrypt a file. I searched for a 2-way encryption technique and
ended up with ezcrypto gem. I thought to give it a test. I was able to
encrypt the content and store it in a file but getting errors while
decrypting the file content and writing to console. I couldn't figure
out the problem. here is my code
require 'rubygems'
require 'ezcrypto'
@key = EzCrypto::Key.with_password "private documents","salted hash"
file1 = File.new("crypto.txt", "w")
@encrypted = @key.encrypt "These are private documents"
file1.puts @encrypted
file1.close
puts "Here is the content"
file2 = File.read("crypto.txt")
puts @key.decrypt file2
Can anyone figure out the problem? or suggest me a different crypting
technique other than ezcrypto or suggest me a ruby app implementing such
a requirement..
or a code snippet
any help appreciated
thanks®ards,
Venkat
Attachments:
http://www.ruby-forum.com/attachment/304/test.rb