benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 792307d5-ec43-52d1-b076-c41d4946d841

Problem

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

complete prompt

import base64
from cryptography.fernet import Fernet

def task_func(message, encryption_key):
    """
    Encrypts a message with a symmetric encryption key using Fernet encryption, and then encode the 
    encrypted message using base64.

    Parameters:
    message (str): The message to be encrypted and encoded.
    encryption_key (str): The key used for symmetric encryption. It should be a string, which will 
                          be encoded to bytes, then URL-safe base64 encoded to conform to the requirements 
                          for Fernet (32 bytes after encoding).

    Returns:
    str: The base64 encoded encrypted message. The message is first encrypted using Fernet encryption, 
         then the result is base64 encoded.

    Requirements:
    - base64
    - cryptography.fernet

    Example:
    >>> encrypted_message = task_func('Hello, World!', '01234567890123456789012345678901')
    >>> isinstance(encrypted_message, str)
    True
    """

instruct prompt

Encrypts a message with a symmetric encryption key using Fernet encryption, and then encode the encrypted message using base64.
The function should output with:
    str: The base64 encoded encrypted message. The message is first encrypted using Fernet encryption,
    then the result is base64 encoded.
You should write self-contained code starting with:

Code

import base64
from cryptography.fernet import Fernet
def task_func(message, encryption_key):

code prompt

Code

import base64
from cryptography.fernet import Fernet
def task_func(message, encryption_key):

entry point

task_func

libs

  • base64
  • cryptography

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