benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 23dc3ab6-d5a0-5a93-b009-668a90f337ce

Problem

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

complete prompt

import hashlib
import rsa
import base64


def task_func(file_path):
    """
    Generates a signed hash of a file's contents using RSA encryption. The file's contents are hashed using SHA-256,
    and then the hash is signed with a private RSA key stored in 'private.pem'. The signed hash is encoded in base64.

    Parameters:
    file_path (str): The path to the file whose contents are to be signed.

    Returns:
    str: The base64 encoded signed hash of the file.

    Requirements:
    - hashlib
    - rsa
    - base64

    Examples:
    Assuming 'example.txt' contains some text and a valid 'private.pem' is present,
    >>> len(task_func('example.txt')) > 0
    True

    Assuming 'empty.txt' is an empty file and a valid 'private.pem' is present,
    >>> len(task_func('empty.txt')) > 0
    True
    """

instruct prompt

Generates a signed hash of a file's contents using RSA encryption. The file's contents are hashed using SHA-256, and then the hash is signed with a private RSA key stored in 'private.pem'. The signed hash is encoded in base64. Assuming 'empty.txt' is an empty file and a valid 'private.pem' is present, >>> len(task_func('empty.txt')) > 0 True
The function should output with:
    str: The base64 encoded signed hash of the file.
You should write self-contained code starting with:

Code

import hashlib
import rsa
import base64
def task_func(file_path):

code prompt

Code

import hashlib
import rsa
import base64
def task_func(file_path):

entry point

task_func

libs

  • base64
  • rsa
  • 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