benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 6dbcb0d7-6702-58aa-9da2-a9a26a1229cf

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import hashlib
import base64


def task_func(filename, data, password):
    """
    Encrypt a string with a password, then write the encrypted string to a file. 
    If the file or directory does not exist, create it.

    Parameters:
    filename (str): The name of the file to write to.
    data (str): The string to encrypt and write to the file.
    password (str): The password to use for encryption.

    Returns:
    str: The encrypted string.

    Requirements:
    - hashlib
    - base64

    Example:
    >>> task_func('test.txt', 'Hello, World!', 'password')
    'Fu0k9LUEJCY+ookLrA=='
    """

instruct prompt

Encrypt a string with a password, then write the encrypted string to a file. If the file or directory does not exist, create it.
The function should output with:
    str: The encrypted string.
You should write self-contained code starting with:

Code

import hashlib
import base64
def task_func(filename, data, password):

code prompt

Code

import hashlib
import base64
def task_func(filename, data, password):

entry point

task_func

libs

  • base64
  • hashlib

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import