rowy icon indicating copy to clipboard operation
rowy copied to clipboard

Error when executing argon2 code in Buildship

Open adrfinance opened this issue 1 year ago • 0 comments
trafficstars

Describe the bug A code which uses argon2 fails to execute correctly

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Buildship'
  2. Click on 'New node'
  3. Use the following code:
import argon2 from 'argon2'

async function hashPassword(password) {
  try {
    // Hash password
    const hash = await argon2.hash(password);

    // Store the hash in your database or wherever you manage passwords
    console.log('Hash:', hash);
  } catch (err) {
    console.error('Error hashing password:', err);
  }
}

async function verifyPassword(hash, password) {
  try {
    // Verify password
    const isValid = await argon2.verify(hash, password);
    
    if (isValid) {
      console.log('Password is valid');
    } else {
      console.log('Password is invalid');
    }
  } catch (err) {
    console.error('Error verifying password:', err);
  }
}

// Example usage
const passwordToHash = 'securePassword123';
hashPassword(passwordToHash);

// In a real-world scenario, you would store the hash and then later verify the password
// For demonstration purposes, we'll immediately verify the password after hashing
verifyPassword('$argon2id$v=19$m=65536,t=2,p=1$9S6axxfv...exampleHash', passwordToHash);
  1. See error

Expected behavior Expected was for the code to return the hashed password

Screenshots If applicable, add screenshots to help explain your problem.

Rowy Run version If applicable, share the Rowy Run version from your project settings.

Desktop (please complete the following information): Windows, Chrome latest version

Smartphone (please complete the following information): Through web

Additional context None

adrfinance avatar Feb 02 '24 09:02 adrfinance