def binary_decrypt(encrypted_string, header: Header.new)
      return if encrypted_string.nil?

      str = encrypted_string.to_s
      str.force_encoding(SymmetricEncryption::BINARY_ENCODING)
      return str if str.empty?

      offset = header.parse(str)
      data   = offset.positive? ? str[offset..-1] : str

      openssl_cipher = ::OpenSSL::Cipher.new(header.cipher_name || cipher_name)
      openssl_cipher.decrypt
      openssl_cipher.key  = header.key || @key
      if (iv              = header.iv || @iv)
        openssl_cipher.iv = iv
      end
      result = openssl_cipher.update(data)
      result << openssl_cipher.final
      header.compressed? ? Zlib::Inflate.inflate(result) : result
    end
def binary_decrypt(encrypted_string, header: Header.new)
      return if encrypted_string.nil?

      str = encrypted_string.to_s
      str.force_encoding(SymmetricEncryption::BINARY_ENCODING)
      return str if str.empty?

      offset = header.parse(str)
      data   = offset.positive? ? str[offset..-1] : str

      openssl_cipher = ::OpenSSL::Cipher.new(header.cipher_name || cipher_name)
      openssl_cipher.decrypt
      openssl_cipher.key  = header.key || @key
      if (iv              = header.iv || @iv)
        openssl_cipher.iv = iv
      end
      result = openssl_cipher.update(data)
      result << openssl_cipher.final
      header.compressed? ? Zlib::Inflate.inflate(result) : result
    end
Advanced use only
 See #decrypt to decrypt encoded strings

 Returns a Binary decrypted string without decoding the string first
 The returned string has BINARY encoding

 Decryption of supplied string
   Returns the decrypted string
   Returns nil if encrypted_string is nil
   Returns '' if encrypted_string == ''

 Parameters
   encrypted_string [String]
     Binary encrypted string to decrypt

   header [SymmetricEncryption::Header]
     Optional header for the supplied encrypted_string

 Reads the 'magic' header if present for key, iv, cipher_name and compression

 encrypted_string must be in raw binary form when calling this method

 Creates a new OpenSSL::Cipher with every call so that this call
 is thread-safe and can be called concurrently by multiple threads with
 the same instance of Cipher

 Note:
   When a string is encrypted and the header is used, its decrypted form
   is automatically set to the same UTF-8 or Binary encoding