是base64编码的url安全吗? [英] is base64 encoding url safe?
本文介绍了是base64编码的url安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是node.bcrypt.js散列node.js中输入密码返回十六进制数重置令牌。
user.reset_password_token =要求('密码')。randomBytes(32)的ToString(十六进制
);
我应该还采用base64 EN code在我身边通过它在URL中的令牌(即:链接复位电子邮件)?
有什么好处,这样做呢?
我似乎记得base64编码可以包含正斜杠这将陷入困境的路径:
VAR令牌= user.reset_password_token; //就是那里做base64编码任何好处?
变种EN coded_token =新的缓冲区(令牌)的ToString('的base64'); VAR reset_link =EN http://example.com/reset/'+ coded_token;
sendResetLink(reset_link);
解决方案
I'm using a node.bcrypt.js hash returning hex numbers in node.js for a password reset token.
user.reset_password_token = require('crypto').randomBytes(32).toString('hex'
);
Should I also base64 encode the token before I pass it around in urls (ie: link reset email)?
Is there any benefit to doing this?
I seem to recall base64 encoding can contain forward slashes which would mess up the path:
var token = user.reset_password_token;
//is there any benefit to doing base64 encoding?
var encoded_token = new Buffer(token).toString('base64');
var reset_link = 'http://example.com/reset/'+ encoded_token;
sendResetLink( reset_link );
解决方案
base64 can indeed contain forward slashes, but base32 can't!
这篇关于是base64编码的url安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文