问题描述
- 用node使用crypto模块测试时页面显示Not a string or buffer是怎么回事
-
页面显示的结果
Not a string or bufferTypeError: Not a string or buffer
at TypeError (native)
at Hash.update (crypto.js:119:16)
at f:
odeox
outesindex.js:36:22
at Layer.handle as handle_request
at next (f:
odeox
ode_modulesexpresslib
outer
oute.js:131:13)
at Route.dispatch (f:
odeox
ode_modulesexpresslib
outer
oute.js:112:3)
at Layer.handle as handle_request
at f:
odeox
ode_modulesexpresslib
outerindex.js:277:22
at Function.process_params (f:
odeox
ode_modulesexpresslib
outerindex.js:330:12)
at next (f:
odeox
ode_modulesexpresslib
outerindex.js:271:10)我的代码:
router.post('/signup',function(req,res){ var name = req.body.name, password = req.body.password, password_re = req.body['password-repeat']; if(password_re != password){ req.flash('error','两次输入的密码不一样!'); return res.redirect('/signup'); } //生成md5 var md5 = crypto.createHash('md5'), password = md5.update(req.body.password).digest('hex'); var newUser = new User({ name:req.body.name, password:password, email:req.body.email }); User.get(newUser.name,function(err,user){ if(user){ req.flash('error','用户已经存在'); return res.redirect('/signup'); } newUser.save(function(err,user){ if(err){ req.flash('error',err); return res.redirect('/signup'); } req.session.user = user; req.flash('success','注册成功!'); res.redirect('/'); }); }); });
解决方案
https://cnodejs.org/topic/504061d7fef591855112bab5
解决方案二:
java.lang.StringIndexOutOfBoundsException: String index out of range: 1这是怎么回事?
weblogic 配置 connectionpool Exception :JDBC driver is not on the CLASSPATH错误是怎么回事!(解决方法)