benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 540d61c6-32a4-59ec-a51b-a99462651f96
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import base64
import hashlib
import os
def task_func(password, SALT_LENGTH = 32):
"""
Hashes a password using the PBKDF2 HMAC algorithm with SHA-256 as the hashing algorithm,
combined with a randomly generated salt, and returns both the salt and the hashed password,
each base64-encoded.
Parameters:
password (str): The password to be hashed.
SALT_LENGTH (int): the length of the randomly generated salt.
Returns:
tuple[bytes, bytes]: A tuple containing the base64-encoded salt and the base64-encoded hashed password as byte strings.
Raises:
ValueError if the password is None or empty
Requirements:
- base64
- hashlib
- os
Example:
>>> salt, hashed_password = task_func('my_password')
>>> isinstance(salt, bytes)
True
>>> isinstance(hashed_password, bytes)
True
"""
instruct prompt
Hashes a password using the PBKDF2 HMAC algorithm with SHA-256 as the hashing algorithm, combined with a randomly generated salt, and returns both the salt and the hashed password, each base64-encoded.
The function should raise the exception for: ValueError if the password is None or empty
The function should output with:
tuple[bytes, bytes]: A tuple containing the base64-encoded salt and the base64-encoded hashed password as byte strings.
You should write self-contained code starting with:
Code
import base64
import hashlib
import os
def task_func(password, SALT_LENGTH = 32):
code prompt
Code
import base64
import hashlib
import os
def task_func(password, SALT_LENGTH = 32):
entry point
task_func
libs
- base64
- hashlib
- os
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
initial import