CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-crypto-browserify

tessl install tessl/npm-crypto-browserify@3.12.0

Browser-compatible implementation of Node.js crypto module providing cryptographic operations in web environments.

Agent Success

Agent success rate when using this tile

100%

Improvement

Agent success rate improvement when using this tile compared to baseline

1x

Baseline

Agent success rate without this tile

100%

task.mdevals/scenario-1/

Password-Based Encryption Key Generator

A secure password storage and encryption key derivation utility that creates cryptographic keys from user passwords.

Capabilities

Generates encryption keys from passwords

  • Given password "mySecurePassword", salt "randomSalt123", 10000 iterations, and 32-byte key length using sha256, generates a consistent 32-byte encryption key @test
  • Given password "test123", salt "salt456", 5000 iterations, and 16-byte key length using sha1, generates a consistent 16-byte encryption key @test

Handles different hash algorithms

  • Using sha256 algorithm produces different keys than sha512 for the same password and salt @test
  • Using sha512 algorithm with password "password", salt "salt", 1000 iterations, and 64-byte key length generates a valid 64-byte key @test

Validates security parameters

  • Higher iteration counts (100000 vs 1000) produce different keys for the same password and salt @test
  • Different salts ("salt1" vs "salt2") produce different keys for the same password @test

Supports asynchronous key derivation

  • Deriving a key asynchronously with password "async", salt "test", 5000 iterations, 32 bytes, sha256 returns the key via callback @test
  • Asynchronous derivation produces the same key as synchronous derivation for identical inputs @test

Implementation

@generates

API

/**
 * Synchronously derives an encryption key from a password.
 *
 * @param {string|Buffer} password - The password to derive the key from
 * @param {string|Buffer} salt - Cryptographic salt to prevent rainbow table attacks
 * @param {number} iterations - Number of iterations (higher = more secure but slower)
 * @param {number} keyLength - Desired key length in bytes
 * @param {string} algorithm - Hash algorithm to use (e.g., 'sha256', 'sha512', 'sha1')
 * @returns {Buffer} The derived encryption key
 */
function deriveKeySync(password, salt, iterations, keyLength, algorithm) {
  // IMPLEMENTATION HERE
}

/**
 * Asynchronously derives an encryption key from a password.
 *
 * @param {string|Buffer} password - The password to derive the key from
 * @param {string|Buffer} salt - Cryptographic salt to prevent rainbow table attacks
 * @param {number} iterations - Number of iterations (higher = more secure but slower)
 * @param {number} keyLength - Desired key length in bytes
 * @param {string} algorithm - Hash algorithm to use (e.g., 'sha256', 'sha512', 'sha1')
 * @param {function} callback - Callback function(err, key) called with the derived key
 */
function deriveKey(password, salt, iterations, keyLength, algorithm, callback) {
  // IMPLEMENTATION HERE
}

module.exports = {
  deriveKey,
  deriveKeySync
};

Dependencies { .dependencies }

crypto-browserify { .dependency }

Provides password-based key derivation functionality for generating encryption keys from passwords.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/crypto-browserify@3.12.x
tile.json