Answer the question
In order to leave comments, you need to log in
How to solve the problem with the execution of the node.js script?
Hello everyone, I'm new to JS, familiar with the syntax since yesterday. I'm trying to start a server that will encrypt the text sent to it by a post request, but I ran into an error:
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
at Function.from (buffer.js:333:9)
at c:\Users\artur\Desktop\Coding\server for naga.com\app.js:6:25
at Layer.handle [as handle_request] (c:\Users\artur\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (c:\Users\artur\node_modules\express\lib\router\index.js:317:13)
at c:\Users\artur\node_modules\express\lib\router\index.js:284:7
at Function.process_params (c:\Users\artur\node_modules\express\lib\router\index.js:335:12)
at next (c:\Users\artur\node_modules\express\lib\router\index.js:275:10)
at expressInit (c:\Users\artur\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request] (c:\Users\artur\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (c:\Users\artur\node_modules\express\lib\router\index.js:317:13)
const crypto = require('crypto');
const express = require("express");
const app = express();
app.use("/generate", function(request, response){
const password = Buffer.from(request.query.password, 'base64');
const hash = crypto.createHash('sha256')
.update("$2a$10$0.o/S/w/i/p/e/S/A/L/T/"+password)
.digest('base64');
response.end('HASH:'+ hash + ';')
});
app.listen(5555);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question