Sha256: 77a84e62c92ffbadcfc63f4b38e4407623027a12de86c37e1baec72278a0cd85

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'
require 'openssl'

describe Encryption do
  
  it 'should be configurable with a block' do
    key = String.random
    iv = String.random
    cipher = String.random

    Encryption.config do |config|
      config.key = key
      config.iv = iv
      config.cipher = cipher
    end

    Encryption.key.should == key
    Encryption.iv.should == iv
    Encryption.cipher.should == cipher
  end

  %x(openssl list-cipher-commands).split.each do |cipher|
    next if ['base64', 'zlib'].include? cipher
    
    describe 'with cipher ' + cipher do
      before(:each) do
        Encryption.cipher = cipher

        @string = String.random
        Encryption.key = String.random
        Encryption.iv = String.random
      end

      it 'should generate encryption different then the original string' do
        encrypted = Encryption.encrypt(@string)
        encrypted.should_not == @string
      end

      it 'should decrypt, encrypted values and match the original string' do
        encrypted = Encryption.encrypt(@string)
        decrypted = Encryption.decrypt(encrypted)
        decrypted.should == @string
      end

    end
  end
    
end 

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
encryption-1.1.8 spec/encryption/symmetric_global_spec.rb
encryption-1.1.7 spec/encryption/symmetric_global_spec.rb
encryption-1.1.6 spec/encryption/symmetric_global_spec.rb
encryption-1.1.5 spec/encryption/symmetric_global_spec.rb
encryption-1.1.4 spec/encryption/symmetric_global_spec.rb
encryption-1.1.3 spec/encryption/symmetric_global_spec.rb
encryption-1.1.2 spec/encryption/symmetric_global_spec.rb