brute force test

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
brute force test 4
const crypto = require('crypto');

function generateRandomHexKey(length) {
    return crypto.randomBytes(length).toString('hex').substring(0, length);
}

function bruteForceHexKey(key) {
    const start = process.hrtime.bigint();
    
    let attempt = 0;
    let hexAttempt = '';

    while (hexAttempt !== key) {
        hexAttempt = attempt.toString(16).padStart(key.length, '0');
        attempt++;
    }

    const end = process.hrtime.bigint();

    return Number(end - start) / 1e9;  // Convert nanoseconds to seconds
}

const keyLength = 4;  // Adjust key length as needed
const key = generateRandomHexKey(keyLength);

console.log(`Starting brute force of key ${key}`);
const timeTaken = bruteForceHexKey(key);
console.log(`Brute force of key ${key} took ${timeTaken.toFixed(2)} seconds.`);
ready
brute force test 5
const crypto = require('crypto');

function generateRandomHexKey(length) {
    return crypto.randomBytes(length).toString('hex').substring(0, length);
}

function bruteForceHexKey(key) {
    const start = process.hrtime.bigint();
    
    let attempt = 0;
    let hexAttempt = '';

    while (hexAttempt !== key) {
        hexAttempt = attempt.toString(16).padStart(key.length, '0');
        attempt++;
    }

    const end = process.hrtime.bigint();

    return Number(end - start) / 1e9;  // Convert nanoseconds to seconds
}

const keyLength = 4;  // Adjust key length as needed
const key = generateRandomHexKey(keyLength);

console.log(`Starting brute force of key ${key}`);
const timeTaken = bruteForceHexKey(key);
console.log(`Brute force of key ${key} took ${timeTaken.toFixed(2)} seconds.`);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.