Sha256: ea8b81af3cf68ed40e89bf7eb05e74a22b391af3e07d26cc82880dd013353863
Contents?: true
Size: 742 Bytes
Versions: 5
Compression:
Stored size: 742 Bytes
Contents
module AttrKeyring module Encryptor class AES def self.build_cipher OpenSSL::Cipher.new(cipher_name) end def self.key_size @key_size ||= build_cipher.key_len end def self.encrypt(key, message) cipher = build_cipher cipher.encrypt iv = cipher.random_iv cipher.iv = iv cipher.key = key iv + cipher.update(message) + cipher.final end def self.decrypt(key, message) cipher = build_cipher cipher.decrypt iv = message[0...cipher.iv_len] encrypted = message[cipher.iv_len..-1] cipher.iv = iv cipher.key = key cipher.update(encrypted) + cipher.final end end end end
Version data entries
5 entries across 5 versions & 1 rubygems