【发布时间】:2014-01-29 03:46:58
【问题描述】:
我正在用 C++ 制作一个小型密码强度计算器,它将计算密码的信息熵值以及 NIST 值。我有程序的熵部分工作,但 NIST 部分给了我一些问题。我很确定我有正确的公式,但是每次我输入测试密码时,我知道应该给我一个 24 的值,我得到一个 18 的值。我在我的代码中没有看到会导致这种情况的问题让我相信这是公式的问题。是否有人熟悉 NIST 公式并可以为我提供帮助?任何帮助将不胜感激。我在下面附上了我的代码。
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main(){
string eight_password, first_char, next_seven;
int ep_length;
double ent_strength, nist_strength;
const int NIST_FIRST = 4, NIST_SEVEN = 2, NIST_REM = 1;
const double NIST_TWELVE = 1.5;
cout << "Hello! Please enter a password of 8 characters or less (including spaces!):" << endl;
getline(cin, eight_password);
ep_length = eight_password.length();
ent_strength = (ep_length*((log(94))/(log(2))));
first_char = eight_password.substr(0, 1);
next_seven = eight_password.substr(1, 7);
nist_strength = (first_char.length()*NIST_FIRST) + (next_seven.length()*NIST_SEVEN);
cout << nist_strength<<endl;
cout << first_char.length() << endl;
cout << next_seven.length() << endl;
return 0;
}
【问题讨论】:
-
如果您添加到规范的链接会提供帮助
-
Go Here 并向下滚动到“NIST Special Publication 800-63”
标签: c++ password-encryption entropy