Get password from input using node.js

前端 未结 4 1454
梦谈多话
梦谈多话 2021-02-02 09:29

How to get password from input using node.js? Which means you should not output password entered in console.

4条回答
  •  南旧
    南旧 (楼主)
    2021-02-02 09:47

    You can use the read module (disclosure: written by me) for this:

    In your shell:

    npm install read
    

    Then in your JS:

    var read = require('read')
    read({ prompt: 'Password: ', silent: true }, function(er, password) {
      console.log('Your password is: %s', password)
    })
    

提交回复
热议问题