Sha256: 23dfc789c7b28f0c892c7451ec0c8afc98c7d2a225e9cc460947933520a74e1a

Contents?: true

Size: 577 Bytes

Versions: 27

Compression:

Stored size: 577 Bytes

Contents

# coding: utf-8
module Reapal
  module Encrypt
    module AES

      def self.encrypt(content, key)
        cipher = OpenSSL::Cipher.new("AES-128-ECB")
        cipher.encrypt
        cipher.key = key
        encrypted = cipher.update(content) + cipher.final
        Base64.strict_encode64(encrypted)
      end

      def self.decrypt(content, key)
        encrypted = Base64.strict_decode64(content)
        cipher = OpenSSL::Cipher.new("AES-128-ECB")
        cipher.decrypt
        cipher.key = key
        cipher.update(encrypted) + cipher.final
      end

    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
reapal-0.18.0 lib/reapal/encrypt/aes.rb
reapal-0.17.0 lib/reapal/encrypt/aes.rb
reapal-0.16.0 lib/reapal/encrypt/aes.rb
reapal-0.15.0 lib/reapal/encrypt/aes.rb
reapal-0.14.0 lib/reapal/encrypt/aes.rb
reapal-0.13.0 lib/reapal/encrypt/aes.rb
reapal-0.12.0 lib/reapal/encrypt/aes.rb
reapal-0.11.0 lib/reapal/encrypt/aes.rb
reapal-0.10.1 lib/reapal/encrypt/aes.rb
reapal-0.10.0 lib/reapal/encrypt/aes.rb
reapal-0.9.13 lib/reapal/encrypt/aes.rb
reapal-0.9.12 lib/reapal/encrypt/aes.rb
reapal-0.9.11 lib/reapal/encrypt/aes.rb
reapal-0.9.10 lib/reapal/encrypt/aes.rb
reapal-0.9.9 lib/reapal/encrypt/aes.rb
reapal-0.9.7 lib/reapal/encrypt/aes.rb
reapal-0.9.6 lib/reapal/encrypt/aes.rb
reapal-0.9.5 lib/reapal/encrypt/aes.rb
reapal-0.9.3 lib/reapal/encrypt/aes.rb
reapal-0.9.2 lib/reapal/encrypt/aes.rb