You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: encrypted_data_bag_item_spec.rb
    path of file: ./repos/chef/spec/unit
    
    the code of the file until where you have to start completion: #
# Author:: Seth Falcon (<seth@chef.io>)
# Copyright:: Copyright (c) Chef Softwa
    
  def self.encrypt_value(plaintext_data, key)
    data = plaintext_data.to_yaml

    cipher = OpenSSL::Cipher.new("aes-256-cbc")
    cipher.encrypt
    cipher.pkcs5_keyivgen(key)
    encrypted_bytes = cipher.update(data)
    encrypted_bytes << cipher.final
    Base64.encode64(encrypted_bytes)
  end