How to use Scrypt in Javascript

I want to hash passwords using Scrypt for that; I want to use this [package].(Scrypt-js NPM | npm.io)
Here is my code

import 'scrypt-js';
const N = 1024, r = 8, p = 1;
const dkLen = 32;
const password = new buffer.SlowBuffer("123456".normalize('NFKC'));
const salt = new buffer.SlowBuffer("[email protected]".normalize('NFKC'));
var t = scrypt.syncScrypt(password,salt,N,r,p,dkLen);
console.log(t);

And here is my log
I’m having this error

Uncaught ReferenceError ReferenceError: buffer is not defined
    at <anonymous> (g:\m.stepn.com\test.js:4:18)
    at run (internal/modules/esm/module_job:193:25)
    --- await ---
    at processTicksAndRejections (internal/process/task_queues:95:5)
    --- await ---
    at runMainESM (internal/modules/run_main:55:21)
    at executeUserEntryPoint (internal/modules/run_main:78:5)
    at <anonymous> (internal/main/run_main_module:17:47)

anybody know how to solve it I’m new in Javascript

First: npm i scryptsy

BLOCK:ConstantString
LABEL:KEY
  value = $"<input.PASS>"
  => VAR @key
ENDBLOCK

BLOCK:Reverse
LABEL:SALT
  input = @key
  => VAR @salt
ENDBLOCK

BLOCK:Script
LABEL:BASE64
INTERPRETER:NodeJS
INPUT key,salt
BEGIN SCRIPT
var scrypt = require('scryptsy');

var key = (key);
var salt = (salt);
var hash = scrypt(key, salt, 16384, 8, 1, 64);
var hashed = (hash.toString('base64'));
END SCRIPT
OUTPUT String @hashed
ENDBLOCK

this example u can use the parameters u needs.

1 Like

If I want the hash type, not base64 but a unit array

change base64 to hex

BLOCK:Script
LABEL:HEX
INTERPRETER:NodeJS
INPUT key,salt
BEGIN SCRIPT
var scrypt = require('scryptsy');

var key = (key);
var salt = (salt);
var hash = scrypt(key, salt, 1024, 8, 1, 32);
var hashed = (hash.toString('hex'));
END SCRIPT
OUTPUT String @hashed
ENDBLOCK
1 Like

Why we use BLOCK:Reverse LABEL:SALT input = @key => VAR @salt ENDBLOCK reverse block here

this is only a example.
i said before: this example u can use the parameters u needs.

ahhh ok thank u for your help