Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ModeFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,10 @@ mode ModeFactory::doubles() {
r.function = ModeFunction::Doubles;
return r;
}

mode ModeFactory::startEnd(const char hex) {
mode r;
r.function = ModeFunction::StartEnd;
r.data1[0] = static_cast<cl_uchar>(hexValue(hex));
return r;
}
1 change: 1 addition & 0 deletions ModeFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ModeFactory {
static mode letters();
static mode numbers();
static mode doubles();
static mode startEnd(const char charLeading);
};

#endif /* HPP_MODEFACTORY */
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ usage: ./ERADICATE2 [OPTIONS]
Modes with arguments:
--leading <single hex> Score on hashes leading with given hex character.
--matching <hex string> Score on hashes matching given hex string.
--start-end <hex> Score on hashes start & end with given hex character.

Advanced modes:
--leading-range Scores on hashes leading with characters within
Expand Down
38 changes: 37 additions & 1 deletion eradicate2.cl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
enum ModeFunction {
Benchmark, ZeroBytes, Matching, Leading, Range, Mirror, Doubles, LeadingRange
Benchmark, ZeroBytes, Matching, Leading, Range, Mirror, Doubles, LeadingRange, StartEnd
};

typedef struct {
Expand All @@ -23,6 +23,7 @@ void eradicate2_score_matching(const uchar * const hash, __global result * const
void eradicate2_score_range(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round);
void eradicate2_score_leadingrange(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round);
void eradicate2_score_mirror(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round);
void eradicate2_score_startend(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round);
void eradicate2_score_doubles(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round);

__kernel void eradicate2_iterate(__global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round) {
Expand Down Expand Up @@ -69,6 +70,10 @@ __kernel void eradicate2_iterate(__global result * const pResult, __global const
eradicate2_score_mirror(h.b + 12, pResult, pMode, scoreMax, deviceIndex, round);
break;

case StartEnd:
eradicate2_score_startend(h.b + 12, pResult, pMode, scoreMax, deviceIndex, round);
break;

case Doubles:
eradicate2_score_doubles(h.b + 12, pResult, pMode, scoreMax, deviceIndex, round);
break;
Expand Down Expand Up @@ -228,6 +233,37 @@ void eradicate2_score_mirror(const uchar * const hash, __global result * const p
eradicate2_result_update(hash, pResult, score, scoreMax, deviceIndex, round);
}

void eradicate2_score_startend(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round) {
const size_t id = get_global_id(0);
int score = 0;
int err = 0;

for (int i = 0; i < 10 && !err; ++i) {
const uchar leftLeft = (hash[i] & 0xF0) >> 4;
const uchar leftRight = (hash[i] & 0x0F);

const uchar rightLeft = (hash[19 - i] & 0xF0) >> 4;
const uchar rightRight = (hash[19 - i] & 0x0F);

if (leftLeft != rightRight || leftLeft != pMode->data1[0]) {
err = 1;
break;
}

score += 2;

if (leftRight != rightLeft || leftRight != pMode->data1[0]) {
if(leftRight == pMode->data1[0]) ++score;
err = 1;
break;
}

score += 2;
}

eradicate2_result_update(hash, pResult, score, scoreMax, deviceIndex, round);
}

void eradicate2_score_doubles(const uchar * const hash, __global result * const pResult, __global const mode * const pMode, const uchar scoreMax, const uint deviceIndex, const uint round) {
const size_t id = get_global_id(0);
int score = 0;
Expand Down
4 changes: 4 additions & 0 deletions eradicate2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ int main(int argc, char * * argv) {
bool bModeRange = false;
bool bModeMirror = false;
bool bModeDoubles = false;
std::string strModeStartEnd;
int rangeMin = 0;
int rangeMax = 0;
std::vector<size_t> vDeviceSkipIndex;
Expand All @@ -211,6 +212,7 @@ int main(int argc, char * * argv) {
argp.addSwitch('7', "range", bModeRange);
argp.addSwitch('8', "mirror", bModeMirror);
argp.addSwitch('9', "leading-doubles", bModeDoubles);
argp.addSwitch('z', "start-end", strModeStartEnd);
argp.addSwitch('m', "min", rangeMin);
argp.addSwitch('M', "max", rangeMax);
argp.addMultiSwitch('s', "skip", vDeviceSkipIndex);
Expand Down Expand Up @@ -270,6 +272,8 @@ int main(int argc, char * * argv) {
mode = ModeFactory::mirror();
} else if (bModeDoubles) {
mode = ModeFactory::doubles();
} else if (!strModeStartEnd.empty()) {
mode = ModeFactory::startEnd(strModeStartEnd.front());
} else {
std::cout << g_strHelp << std::endl;
return 0;
Expand Down
1 change: 1 addition & 0 deletions help.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ usage: ./ERADICATE2 [OPTIONS]
Modes with arguments:
--leading <single hex> Score on hashes leading with given hex character.
--matching <hex string> Score on hashes matching given hex string.
--start-end <hex> Score on hashes start & end with given hex character.

Advanced modes:
--leading-range Scores on hashes leading with characters within
Expand Down
2 changes: 1 addition & 1 deletion types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#endif

enum class ModeFunction {
Benchmark, ZeroBytes, Matching, Leading, Range, Mirror, Doubles, LeadingRange
Benchmark, ZeroBytes, Matching, Leading, Range, Mirror, Doubles, LeadingRange, StartEnd
};

typedef struct {
Expand Down