0

そこで、CUDA で文字列を照合して比較するブルート フォース文字列ジェネレータを作成しようとしています。よくわからない言語をいじり始める前に、C++ で動作させたいと思っていました。私は現在このコードを持っています。

#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;


int sLength = 0;
int count = 0;
int charReset = 0;
int stop = 0;
int maxValue = 0;
string inString = "";
static const char charSet[] = //define character set to draw from
"0123456789"
"!@#$%^&*"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int stringLength = sizeof(charSet) - 1;


char genChars()
{
        return charSet[count]; //Get character and send to genChars()
}

int main()
{
    cout << "Length of string to match?" << endl;
    cin >> sLength;
    cout << "What string do you want to match?" << endl;
    cin >> inString;
    string sMatch(sLength, ' ');
    while(true)
    {
        for (int y = 0; y < sLength; y++)
        {
            sMatch[y] = genChars(); //get the characters
            cout << sMatch[y];

            if (count == 74)
            {
                charReset + 1;
                count = 0;
            }
            if (count == 2147000000)
            {
                count == 0;
                maxValue++;
            }
        }
        count++;
        if (sMatch == inString) //check for string match
        {
            cout << endl;
            cout << "It took " << count + (charReset * 74) + (maxValue*2147000000) << " randomly generated characters to match the strings." << endl;
            cin >> stop;
        }
        cout << endl;
    }
}

これで、このコードは実行およびコンパイルされますが、私が望んでいることは正確には実行されません。同じキャラクターのEXを4つやります。aaaa または 1111 そして aaab または 1112 のようにインクリメントせずに次へ進みます。私はこのようなことをいじってみました

for (int x = 0; x < sLength; x++)
{
    return charSet[count-sLength+x];
}

私の心の中ではうまくいくはずですが、役に立ちません。

4

1 に答える 1