benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf d60601a1-3679-570b-884a-e517266d158a

Problem

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

complete prompt

import hashlib
import hmac

def task_func(secret, message):
    """
    Generates an HMAC (Hash-based Message Authentication Code) signature for a given message using a secret key.
    The function uses SHA-256 as the hash function to create the HMAC signature.

    Parameters:
    secret (str): The secret key used for HMAC generation.
    message (str): The message for which the HMAC signature is to be generated.

    Returns:
    str: The HMAC signature of the message, returned as a hexadecimal string.

    Requirements:
    - hashlib
    - hmac

    Examples:
    Generate an HMAC signature for a message.
    >>> len(task_func('mysecretkey', 'Hello, world!')) == 64
    True

    Generate an HMAC for a different message with the same key.
    >>> len(task_func('mysecretkey', 'Goodbye, world!')) == 64
    True
    """

instruct prompt

Generates an HMAC (Hash-based Message Authentication Code) signature for a given message using a secret key. The function uses SHA-256 as the hash function to create the HMAC signature. Generate an HMAC for a different message with the same key. >>> len(task_func('mysecretkey', 'Goodbye, world!')) == 64 True
The function should output with:
    str: The HMAC signature of the message, returned as a hexadecimal string.
You should write self-contained code starting with:

Code

import hashlib
import hmac
def task_func(secret, message):

code prompt

Code

import hashlib
import hmac
def task_func(secret, message):

entry point

task_func

libs

  • hmac
  • 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