diff --git a/config/initializers/hexapdf.rb b/config/initializers/hexapdf.rb index a51bbaef..420d6895 100644 --- a/config/initializers/hexapdf.rb +++ b/config/initializers/hexapdf.rb @@ -1,6 +1,18 @@ # frozen_string_literal: true module HexaPDF + module Encryption + class SecurityHandler + def encrypt_string(str, obj) + return str.dup if str.empty? || obj == document.trailer[:Encrypt] || obj.type == :XRef || + (obj.type == :Sig && obj[:Contents].equal?(str)) + + key = object_key(obj.oid, obj.gen, string_algorithm) + string_algorithm.encrypt(key, str).dup + end + end + end + module Type # fix NoMethodError: undefined method `field_value' for #