benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 406b1f11-92de-5896-a269-24db9b84b9eb

Problem

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

complete prompt

import base64
import binascii
import os
import hashlib

def task_func(hex_str, salt_size):
    """
    Converts a hex string to bytes, salts it with a random value of specified size, and computes its SHA256 hash.
    The function generates a random salt of the specified size, appends it to the byte representation of the hex string,
    and then computes the SHA256 hash of the salted data. The salt and hash are returned as a tuple.

    Parameters:
        hex_str (str): The hex string to be hashed.
        salt_size (int): The size of the salt in bytes to generate.

    Returns:
        tuple: A tuple containing the base64-encoded salt and the SHA256 hash.

    Requirements:
    - base64
    - binascii
    - os
    - hashlib

    Examples:
    >>> result = task_func("F3BE8080", 16)
    >>> isinstance(result, tuple) and len(result) == 2
    True
    >>> isinstance(result[0], str) and isinstance(result[1], str)
    True
    """

instruct prompt

Converts a hex string to bytes, salts it with a random value of specified size, and computes its SHA256 hash. The function generates a random salt of the specified size, appends it to the byte representation of the hex string, and then computes the SHA256 hash of the salted data. The salt and hash are returned as a tuple.
The function should output with:
    tuple: A tuple containing the base64-encoded salt and the SHA256 hash.
You should write self-contained code starting with:

Code

import base64
import binascii
import os
import hashlib
def task_func(hex_str, salt_size):

code prompt

Code

import base64
import binascii
import os
import hashlib
def task_func(hex_str, salt_size):

entry point

task_func

libs

  • base64
  • hashlib
  • os
  • binascii

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