有人知道我在哪里可以找到带有system.security.cryptography命名空间的示例代码--或者开发人员可以遵循的指令?
其目的是为asp.net网站添加双因素身份验证。在网站上,我想要求用户输入一个密码(类似于他们从键盘上获得的密码)。在客户端,我想提供一个生成正确密码的vb.net windows.forms程序。
我想用一个小规模的system.security.cryptography命名空间来完成这个任务。我正在寻找示例代码,我不想搅乱设备或购买身份验证服务器设备。
大多数算法都需要一个高级的数学学位,或者是其他平台,如Linux或PHP。我在找.net等价物。
发布于 2010-09-13 14:05:39
RFC4226 (基于计数器的OTP)或草案-mraihi-totp-基于时间的 (基于时间的OTP)的密码部分相对简单:
通常是用户管理和静态/动态同步使其变得复杂。
像这样的事情应该有效:
public static int CalculateHotp(byte[] key, byte[] counter)
{
var hmacsha1 = new HMACSHA1(key);
byte[] hmac_result = hmacsha1.ComputeHash(counter);
int offset = hmac_result[19] & 0x0f;
int bin_code = (hmac_result[offset] & 0x7f) << 24
| (hmac_result[offset+1] & 0xff) << 16
| (hmac_result[offset+2] & 0xff) << 8
| (hmac_result[offset+3] & 0xff);
int hotp = bin_code % 1000000;
return hotp;
}https://stackoverflow.com/questions/3693741
复制相似问题