Skip to content

Commit

Permalink
produce evenly folded blocks
Browse files Browse the repository at this point in the history
Fixes #281.
  • Loading branch information
kenyon committed Jan 10, 2021
1 parent ce3fbad commit b12b924
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/hiera/backend/eyaml/encryptor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def self.find encryption_scheme = nil
end

def self.encode binary_string
Base64.encode64(binary_string).strip
Base64.strict_encode64(binary_string)
end

def self.decode string
Expand Down
8 changes: 2 additions & 6 deletions lib/hiera/backend/eyaml/parser/encrypted_tokens.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,12 @@ def to_encrypted(args={})
encryption_method = args[:change_encryption]
if encryption_method != nil
@encryptor = Encryptor.find encryption_method
@cipher = Base64.encode64(@encryptor.encrypt @plain_text).strip
@cipher = Base64.strict_encode64(@encryptor.encrypt(@plain_text))
end
case format
when :block
# strip any white space
@cipher = @cipher.gsub(/[ \t]/, "")
# normalize indentation
ciphertext = @cipher.gsub(/[\n\r]/, "\n" + @indentation)
chevron = (args[:use_chevron].nil? || args[:use_chevron]) ? ">\n" : ''
"#{label_string}#{chevron}" + @indentation + "ENC[#{@encryptor.tag},#{ciphertext}]"
"#{label_string}#{chevron}" + @indentation + "ENC[#{@encryptor.tag},#{@cipher}]".scan(/.{1,60}/).join("\n" + @indentation)
when :string
ciphertext = @cipher.gsub(/[\n\r]/, "")
"#{label_string}ENC[#{@encryptor.tag},#{ciphertext}]"
Expand Down

0 comments on commit b12b924

Please sign in to comment.