brute force test (v2)

Revision 2 of this benchmark created on


Setup

async function generateRandomHexKey(length) {
    const array = new Uint8Array(length);
    window.crypto.getRandomValues(array);
    return Array.from(array).map(b => b.toString(16).padStart(2, '0')).join('').substring(0, length);
}

async function startBruteForce(length) {
    const key = await generateRandomHexKey(length);  // Adjust key length as needed
    console.log('Generated key: ' + key);

    const startTime = performance.now();
    let attempt = 0;
    let hexAttempt = '';

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

    const timeTaken = (performance.now() - startTime) / 1000;  // Convert to seconds
    console.log(`Brute force of key ${key} took ${timeTaken.toFixed(2)} seconds.`);
}

Test runner

Ready to run.

Testing in
TestOps/sec
brute force test 4
startBruteForce(4);

ready
brute force test 5
startBruteForce(5);

ready

Revisions

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