benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf caff9f3d-e9de-5801-9469-dc6aa4cc6199

Problem

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

complete prompt

import codecs
import random
import string
import hashlib

def task_func(password_length=10, salt="salty"):
    """
    Generate a random password of a specified length, including Latin characters, numbers, and symbols. 
    Then, hash the password using the SHA256 algorithm after mixing it with a specified salt.
    
    Parameters:
    - password_length (int, optional): Length of the generated password. Defaults to 10.
    - salt (str, optional): Salt to be added to the password before hashing. Defaults to "salty".
    
    Returns:
    str: The hashed password.
    
    Requirements:
    - codecs
    - random
    - string
    - hashlib
    
    Example:
    >>> random.seed(0)
    >>> hashed_password = task_func(12, "my_salt")
    >>> print(hashed_password)
    a706478dc5969e90dcfc2fbaffff0b9f8e7f2b006002edac13cb17f5bf9ba941
    """

instruct prompt

Generate a random password of a specified length, including Latin characters, numbers, and symbols. Then, hash the password using the SHA256 algorithm after mixing it with a specified salt.
The function should output with:
    str: The hashed password.
You should write self-contained code starting with:

Code

import codecs
import random
import string
import hashlib
def task_func(password_length=10, salt="salty"):

code prompt

Code

import codecs
import random
import string
import hashlib
def task_func(password_length=10, salt="salty"):

entry point

task_func

libs

  • codecs
  • hashlib
  • random
  • string

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