0
我正在C++中製作一個小密碼強度計算器,它將計算密碼的信息熵值以及NIST值。我有程序的熵部分工作,但NIST部分給我一些問題。我很確定我有正確的公式,但每次我把我的測試密碼通過我知道應該給我的值24我得到了18的值。我沒有看到在我的代碼中會導致這個問題導致我相信這是公式的問題。有人熟悉NIST配方,可以提供幫助嗎?任何幫助將不勝感激。下面附上了我的代碼。C++中的密碼強度
#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](http://en.wikipedia.org/wiki/Password_strength),並向下滾動到「NIST Special Publication 800-63」 – user3064203