Sha256: 89c317acb21a5326bca06c0363775f019935b97ffe182fa32685e2a3eb480da5
Contents?: true
Size: 659 Bytes
Versions: 2
Compression:
Stored size: 659 Bytes
Contents
# frozen_string_literal: true require "base64" require "json" require "openssl" require_relative "payload" module ROM module EncryptedAttribute class Encryptor def initialize(derivator:) @derivator = derivator end def encrypt(message) cipher = OpenSSL::Cipher.new("aes-256-gcm") key = @derivator.derive(cipher.key_len) iv = cipher.random_iv cipher.encrypt cipher.key = key cipher.iv = iv encrypted = cipher.update(message) + cipher.final Payload.new(message: encrypted, initialization_vector: iv, auth_tag: cipher.auth_tag).encode end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rom-encrypted_attribute-0.0.4 | lib/rom/encrypted_attribute/encryptor.rb |
rom-encrypted_attribute-0.0.3 | lib/rom/encrypted_attribute/encryptor.rb |