Skip to content

Marshal Objects (e.g. Dates, Integers, etc.) with CryptKeeper

Arthur Nisnevich edited this page Feb 26, 2015 · 1 revision

Create a subclass which performs the marshaling, and use that as the provider:

module CryptKeeper
  module Provider
    class MarshalAes < AesNew
      def encrypt(value)
        super Marshal.dump(value)
      end

      def decrypt(value)
        Marshal.load super(value)
      end
    end
  end
end 

Reference: https://github.com/jmazzi/crypt_keeper/pull/88#issuecomment-76058171