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.9.1 lib/reapal/encrypt/aes.rb
reapal-0.9.0 lib/reapal/encrypt/aes.rb
reapal-0.3.0 lib/reapal/encrypt/aes.rb
reapal-0.2.2 lib/reapal/encrypt/aes.rb
reapal-0.2.1 lib/reapal/encrypt/aes.rb
reapal-0.2.0 lib/reapal/encrypt/aes.rb
reapal-0.1.0 lib/reapal/encrypt/aes.rb