Sha256: a2a850be737f8d51a9f1e86a4e6f337baf44e385506652a33ae12fe4da865620

Contents?: true

Size: 887 Bytes

Versions: 1

Compression:

Stored size: 887 Bytes

Contents

require 'spec_helper'

module CryptKeeperProviders
  describe Aes do
    subject { Aes.new(passphrase: 'cake') }

    describe "#initialize" do
      let(:hexed_key) do
        Digest::SHA1.hexdigest('cake').unpack('a2'*32).map{|x|x.hex}.pack('c'*32)
      end

      it "should extract the key and digest it" do
        subject.key.should == hexed_key
      end
    end

    describe "#encrypt" do
      let(:encrypted) do
        subject.encrypt 'string'
      end

      it "should encrypt the string" do
        encrypted.should_not == 'string'
        encrypted.should_not be_nil
        encrypted.should_not be_empty
      end
    end

    describe "#decrypt" do
      let(:decrypted) do
        subject.decrypt "MC4xODk0NzkyNjkzMTYyMjE4Mzp24QC8s9qRJU9HHbIZKY/x\n"
      end

      it "should decrypt the string" do
        decrypted.should == 'string'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crypt_keeper_providers-0.0.3 spec/aes_spec.rb