Skip to content

Commit 735df43

Browse files
add start-end mode
1 parent 41b8c8e commit 735df43

7 files changed

Lines changed: 52 additions & 2 deletions

File tree

ModeFactory.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,10 @@ mode ModeFactory::doubles() {
8888
r.function = ModeFunction::Doubles;
8989
return r;
9090
}
91+
92+
mode ModeFactory::startEnd(const char hex) {
93+
mode r;
94+
r.function = ModeFunction::StartEnd;
95+
r.data1[0] = static_cast<cl_uchar>(hexValue(hex));
96+
return r;
97+
}

ModeFactory.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ModeFactory {
2323
static mode letters();
2424
static mode numbers();
2525
static mode doubles();
26+
static mode startEnd(const char charLeading);
2627
};
2728

2829
#endif /* HPP_MODEFACTORY */

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ usage: ./ERADICATE2 [OPTIONS]
2323
Modes with arguments:
2424
--leading <single hex> Score on hashes leading with given hex character.
2525
--matching <hex string> Score on hashes matching given hex string.
26+
--start-end <hex> Score on hashes start & end with given hex character.
2627
2728
Advanced modes:
2829
--leading-range Scores on hashes leading with characters within

eradicate2.cl

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
enum ModeFunction {
2-
Benchmark, ZeroBytes, Matching, Leading, Range, Mirror, Doubles, LeadingRange
2+
Benchmark, ZeroBytes, Matching, Leading, Range, Mirror, Doubles, LeadingRange, StartEnd
33
};
44

55
typedef struct {
@@ -23,6 +23,7 @@ void eradicate2_score_matching(const uchar * const hash, __global result * const
2323
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);
2424
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);
2525
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);
26+
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);
2627
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);
2728

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

73+
case StartEnd:
74+
eradicate2_score_startend(h.b + 12, pResult, pMode, scoreMax, deviceIndex, round);
75+
break;
76+
7277
case Doubles:
7378
eradicate2_score_doubles(h.b + 12, pResult, pMode, scoreMax, deviceIndex, round);
7479
break;
@@ -228,6 +233,37 @@ void eradicate2_score_mirror(const uchar * const hash, __global result * const p
228233
eradicate2_result_update(hash, pResult, score, scoreMax, deviceIndex, round);
229234
}
230235

236+
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) {
237+
const size_t id = get_global_id(0);
238+
int score = 0;
239+
int err = 0;
240+
241+
for (int i = 0; i < 10 && !err; ++i) {
242+
const uchar leftLeft = (hash[i] & 0xF0) >> 4;
243+
const uchar leftRight = (hash[i] & 0x0F);
244+
245+
const uchar rightLeft = (hash[19 - i] & 0xF0) >> 4;
246+
const uchar rightRight = (hash[19 - i] & 0x0F);
247+
248+
if (leftLeft != rightRight || leftLeft != pMode->data1[0]) {
249+
err = 1;
250+
break;
251+
}
252+
253+
score += 2;
254+
255+
if (leftRight != rightLeft || leftRight != pMode->data1[0]) {
256+
if(leftRight == pMode->data1[0]) ++score;
257+
err = 1;
258+
break;
259+
}
260+
261+
score += 2;
262+
}
263+
264+
eradicate2_result_update(hash, pResult, score, scoreMax, deviceIndex, round);
265+
}
266+
231267
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) {
232268
const size_t id = get_global_id(0);
233269
int score = 0;

eradicate2.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ int main(int argc, char * * argv) {
189189
bool bModeRange = false;
190190
bool bModeMirror = false;
191191
bool bModeDoubles = false;
192+
std::string strModeStartEnd;
192193
int rangeMin = 0;
193194
int rangeMax = 0;
194195
std::vector<size_t> vDeviceSkipIndex;
@@ -211,6 +212,7 @@ int main(int argc, char * * argv) {
211212
argp.addSwitch('7', "range", bModeRange);
212213
argp.addSwitch('8', "mirror", bModeMirror);
213214
argp.addSwitch('9', "leading-doubles", bModeDoubles);
215+
argp.addSwitch('z', "start-end", strModeStartEnd);
214216
argp.addSwitch('m', "min", rangeMin);
215217
argp.addSwitch('M', "max", rangeMax);
216218
argp.addMultiSwitch('s', "skip", vDeviceSkipIndex);
@@ -270,6 +272,8 @@ int main(int argc, char * * argv) {
270272
mode = ModeFactory::mirror();
271273
} else if (bModeDoubles) {
272274
mode = ModeFactory::doubles();
275+
} else if (!strModeStartEnd.empty()) {
276+
mode = ModeFactory::startEnd(strModeStartEnd.front());
273277
} else {
274278
std::cout << g_strHelp << std::endl;
275279
return 0;

help.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ usage: ./ERADICATE2 [OPTIONS]
2828
Modes with arguments:
2929
--leading <single hex> Score on hashes leading with given hex character.
3030
--matching <hex string> Score on hashes matching given hex string.
31+
--start-end <hex> Score on hashes start & end with given hex character.
3132
3233
Advanced modes:
3334
--leading-range Scores on hashes leading with characters within

types.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#endif
1212

1313
enum class ModeFunction {
14-
Benchmark, ZeroBytes, Matching, Leading, Range, Mirror, Doubles, LeadingRange
14+
Benchmark, ZeroBytes, Matching, Leading, Range, Mirror, Doubles, LeadingRange, StartEnd
1515
};
1616

1717
typedef struct {

0 commit comments

Comments
 (0)