password_hashSecurity

Mock Jutsu HOW-TO | UK

The password_hash function within the mock-jutsu ecosystem provides developers with an efficient method for generating realistic, industry-standard security strings. When building robust authentication systems, it is essential to utilise mock data that mimics the complexity and structure of production environments. This function specifically generates strings that follow the bcrypt algorithm, ensuring that your test data is not only plausible but also compatible with existing database schemas and security validation logic. By using mock-jutsu, teams can ensure their authentication systems are tested against correctly formatted strings without the overhead of manual generation.

Technically, the output generated by mock-jutsu follows the well-recognised bcrypt format: $2b$<cost>$<salt><hash>. Each password_hash produced is exactly 60 characters long, beginning with the $2b$ prefix followed by a cost factor, a 22-character salt, and a 31-character hash. By adhering to this specific standard, the library allows engineers to verify that their systems correctly handle the storage and retrieval of hashed credentials without the need to process or expose actual sensitive information during the development lifecycle. This meticulous attention to formatting ensures that data migration scripts and backend validation rules are thoroughly exercised.

There are numerous testing scenarios where this function proves invaluable. For performance testing, the JMeter integration via ${__mockjutsu(password_hash,)} enables the simulation of high-volume user registration flows with realistic data payloads. In Python-based automation, calling jutsu.generate('password_hash') allows for the rapid creation of mock user objects for unit and integration testing. Additionally, the CLI command "mockjutsu generate password_hash" is perfect for developers who need to seed local databases quickly for UI testing. This versatility ensures that regardless of the toolset, your test data remains consistent and high-quality.

The primary benefit of using mock-jutsu for security-related data is the significant reduction in manual effort and the elimination of security risks. Developers can avoid the pitfalls of using hardcoded or simplistic strings that do not match the expected length or format of real hashes. By automating the creation of a password_hash, teams can focus on building features rather than manually crafting test datasets. This standardised approach to mock data generation ultimately leads to more reliable software and a more streamlined development workflow across the entire project lifecycle.

CLI Usage
mockjutsu generate password_hashmockjutsu bulk password_hash --count 10mockjutsu export password_hash --count 10 --format jsonmockjutsu export password_hash --count 10 --format csvmockjutsu export password_hash --count 10 --format sql# --mask: regulation-compliant output (PCI DSS / GDPR / KVKK)mockjutsu generate password_hash --maskmockjutsu bulk password_hash --count 5 --mask
Python API
from mockjutsu import jutsujutsu.generate('password_hash')jutsu.bulk('password_hash', count=10)jutsu.template(['password_hash'], count=5)# mask=True: regulation-compliant outputjutsu.generate('password_hash', mask=True)jutsu.bulk('password_hash', count=5, mask=True)
JMeter
${__mockjutsu_security(password_hash)}# JMeter Function: __mockjutsu_security# Parameter 1: password_hash# Parameter 2: (not required for this function)# Add 'mask' keyword to get a regulation-compliant masked value${__mockjutsu_security(password_hash,mask)}
REST API
GET /generate/password_hash# → {"type":"password_hash","result":"...","status":"ok"}GET /bulk/password_hash?count=10POST /template {"types":["password_hash"],"count":1}# mask=true: regulation-compliant outputGET /generate/password_hash?mask=trueGET /bulk/password_hash?count=5&mask=true

Parameters

Parameter Values Description
--mask true | false Return a regulation-compliant masked value (PCI DSS, GDPR, KVKK…)

Other Languages