Sha256: a824f7d4f2cf13b94d4f59482f09196d3900a0a9b7fcc1225ee4f2aa2a7dacf8

Contents?: true

Size: 663 Bytes

Versions: 5

Compression:

Stored size: 663 Bytes

Contents

module Rmega
  module Crypto
    module Aes
      extend self

      def packing
        'l>*'
      end

      def cipher
        @cipher ||= OpenSSL::Cipher::AES.new 128, :CBC
      end

      def encrypt key, data
        cipher.reset
        cipher.padding = 0
        cipher.encrypt
        cipher.key = key.pack(packing)
        result = cipher.update data.pack(packing)
        result.unpack packing
      end

      def decrypt key, data
        cipher.reset
        cipher.padding = 0
        cipher.decrypt
        cipher.key = key.pack packing
        result = cipher.update data.pack(packing)
        result.unpack packing
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rmega-0.0.6 lib/rmega/crypto/aes.rb
rmega-0.0.5 lib/rmega/crypto/aes.rb
rmega-0.0.4 lib/rmega/crypto/aes.rb
rmega-0.0.3 lib/rmega/crypto/aes.rb
rmega-0.0.2 lib/rmega/crypto/aes.rb