lib/symmetric_encryption/header.rb in symmetric-encryption-4.0.0 vs lib/symmetric_encryption/header.rb in symmetric-encryption-4.0.1
- old
+ new
@@ -76,11 +76,11 @@
key: nil,
cipher_name: nil,
auth_tag: nil)
@version = version
- @compress = compress
+ @compress = compress
@iv = iv
@key = key
@cipher_name = cipher_name
@auth_tag = auth_tag
end
@@ -109,11 +109,11 @@
# Parameters
# buffer
# String to extract the header from
def parse!(buffer)
offset = parse(buffer)
- return if offset == 0
+ return if offset.zero?
buffer.slice!(0..offset - 1)
buffer
end
# Returns [Integer] the offset within the buffer of the data after the header has been read.
@@ -151,11 +151,17 @@
# Remove header and extract flags
self.version = buffer.getbyte(offset)
offset += 1
- raise(SymmetricEncryption::CipherError, "Cipher with version:#{version.inspect} not found in any of the configured SymmetricEncryption ciphers") unless cipher
+ unless cipher
+ raise(
+ SymmetricEncryption::CipherError,
+ "Cipher with version:#{version.inspect} not found in any of the configured SymmetricEncryption ciphers"
+ )
+ end
+
flags = buffer.getbyte(offset)
offset += 1
self.compress = (flags & FLAG_COMPRESSED) != 0
@@ -253,8 +259,7 @@
len = buffer.byteslice(offset, 2).unpack('v').first
offset += 2
out = buffer.byteslice(offset, len)
[out, offset + len]
end
-
end
end