Similar Question 1 : How do you decrypt a file created with openssl in ruby?
I created a file using:
echo "test" | openssl enc -aes256 -salt -a -k test
def decrypt_string(b64_text, decryption_key) encrypted_text = Base64.decode64(b64_text) _header = encrypted_text[0, 8] salt = encrypted_text[8, 8] payload = encrypted_text[16..-1] decipher = OpenSSL::Cipher.new('aes-256-cbc').decrypt d_1 = OpenSSL::Digest::MD5.new(decryption_key + salt).digest d_2 = OpenSSL::Digest::MD5.new(d_1 + decryption_key + salt).digest decipher.key = (d_1 + d_2) decipher.iv = OpenSSL::Digest::MD5.new(d_2 + decryption_key + salt).digest decipher.update(payload) + decipher.final end
But when I call:
I get OpenSSL::Cipher::CipherError: bad decrypt
I can not use external gems and do not want to make an OS call. How do you use the built in openssl library?
Similar Question 2 : Rails 3 - no such file to load — openssl
when running a Rails server, I get the following error: no such file to load -- openssl
I try a solution I find online. I go to ~/.rvm/src/ruby-1.9.2-head/ext/openssl. I type : ruby extconf.rb, but I get the following:
=== OpenSSL for Ruby configurator === === Checking for system dependent stuff... === checking for t_open() in -lnsl... no checking for socket() in -lsocket... no checking for assert.h... yes === Checking for required stuff... === checking for openssl/ssl.h... no === Checking for required stuff failed. === Makefile wasn't created. Fix the errors above.
I cannot use make nor make install.
Similar Question 3 : Why do I get OpenSSL::SSL::SSLError when installing Rails?
When I run
'sudo gem install rails', this error occurs:
ERROR: While executing gem ... (OpenSSL::SSL::SSLError) SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A
BTW, I'm running Ruby version 1.9.3p0, Gem version 2.0.3, and OpenSSL version OpenSSL 1.0.1.