小编Fer*_*lli的帖子

使用pbkdf2进行SALT和HASH

我使用以下方法从nodejs中的crypto lib创建salted和散列密码:

crypto.randomBytes(size, [callback])
crypto.pbkdf2(password, salt, iterations, keylen, callback)
Run Code Online (Sandbox Code Playgroud)

对于randomBytes调用(创建SALT),我应该使用什么尺寸?我听过128位盐,可能高达256位.看起来这个函数使用的是字节大小,所以我可以假设32(256位)的大小就足够了吗?

对于pbkdf2调用,什么是大量的迭代以及密钥(keylen)的长度是多少?

此外,对于存储,我已经看到了在同一列中存储salt,length,iterations和derviedkey的示例.我正在使用一个分隔4 by的例子::,即:

salt::derivedKey::keyLength::iterations
Run Code Online (Sandbox Code Playgroud)

这样做,然后我可以分开::获取4个值,因此我可以根据提供的密码生成派生密钥,以查看它是否匹配.这是存储它的正确方法吗?或者我应该在结合这些价值观时更具"欺骗性"?

passwords password-storage pbkdf2 node.js

25
推荐指数
1
解决办法
1万
查看次数

如何正确实施免费产品?

如果我列出了一个免费的在线产品,是否有建议的方法在构建其价格而不是0.00美元时使用"免费"这个词?

schema.org/Offer规范说价格的字符串表示必须是类型PriceSpecification,我不确定它的含义.

备选方案#1:

<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <span itemprop="price">Free</span>
    <meta itemprop="priceCurrency" content="USD" />
</div>
Run Code Online (Sandbox Code Playgroud)

备选方案#2:

<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <span itemprop="description">Free</span>
    <meta itemprop="price" content="0" />
    <meta itemprop="priceCurrency" content="USD" />
</div>
Run Code Online (Sandbox Code Playgroud)

我倾向于替代#1(似乎很明显),但我没有找到明确说明使用的参考.

schema.org

9
推荐指数
1
解决办法
2164
查看次数

WCF 4 REST服务无法返回StatusDescription,只能返回StatusCode

我目前正在将我的WCF RESTful服务从.NET 3.5(入门套件)迁移到.NET 4.我使用Visual Studio 2010中的WCF Rest服务模板启动了我的项目.我必须弄清楚如何保留我的授权方案(formely)使用ServiceAuthorizationManager完成RequestInterceptor.经过一些工作和研究,我完成了它.但现在我有了抵押问题.我的服务用于使用HTTP状态代码和简要说明向我的客户反馈任何处理错误.我在服务方法的许多方面使用WebOperationContext来向客户描述出错的地方,如下所示:

protected void returnCode(HttpStatusCode code, string description)
{
    WebOperationContext ctx = WebOperationContext.Current;
    ctx.OutgoingResponse.StatusDescription = description;
    ctx.OutgoingResponse.StatusCode = code;
}
Run Code Online (Sandbox Code Playgroud)

但在WCF 4中,只有StatusCode工作 - StatusDescription静默失败.我无法弄清楚为什么.我唯一的猜测是WebOperationContext在这个新的WCF 4场景中不起作用,我应该使用OperationContext,但这也行不通.在我的自定义类中使用以下方法扩展ServiceAuthorizationManager,通知客户端请求无法访问,因为auth摘要格式错误:

private void GenerateBadDigestMessage(ref OperationContext operationContext)
{
    Message reply = Message.CreateMessage(MessageVersion.None, null, null, new DataContractJsonSerializer(typeof(object)));

    HttpResponseMessageProperty hrp = new HttpResponseMessageProperty();
    hrp.StatusCode = HttpStatusCode.Forbidden;
    hrp.StatusDescription = "bad digest";
    reply.Properties[HttpResponseMessageProperty.Name] = hrp;

    operationContext.RequestContext.Reply(reply);
    operationContext.RequestContext = null;
}
Run Code Online (Sandbox Code Playgroud)

即使在这里使用OperationContext direclty(由WebOperationContext提供),StatusDescription也不起作用.

我在这里缺少什么?为什么这么小的东西可以从.NET 3.5打破到4?

rest wcf http-status-codes operationcontext weboperationcontext

8
推荐指数
1
解决办法
4548
查看次数